No project description provided
Project description
fetch-embed
fetch multilingual embed from embed.ttw.workers.dev
Install it
pip install -U fetch-embed
Use it
Make use of the helper function embed_text
endpoints
for two models (dim-52 and dim-768)
via cloudflare: https://embed.ttw.workers.dev/embed/
and https://embed.ttw.workers.dev/embed_la/
In case you cannot access embed.ttw.workers.dev
, you may use ttw.hopto.org
(hosted by noip.com) instead.
Swagger UI: Self-docs for these endpoints
https://embed.ttw.workers.dev/docs
Model 1: multilingual, dim-512
The default endpoint is https://embed.ttw.workers.dev/embed/
from fetch_embed.embed_text import embed_text
res = embed_text(["test a", "测试"])
print(res.shape)
# (2, 512)
Model 2: language agnostic, dim-768
endpoint: https://embed.ttw.workers.dev/embed_la/
from fetch_embed.embed_text import embed_text
endpoint = "https://embed.ttw.workers.dev/embed_la/"
res = embed_text(["test a", "测试"], endpoint=endpoint)
print(res.shape)
# (2, 768)
Consult the embed_text.__doc__
(e.g. print(embed_text.__doc__)
) or its source code for more details.
Access the API directly
from fetch_embed import fetch_embed
res = fetch_embed("test me")
print(res.shape)
# (1, 512)
print(fetch_embed(["test me", "测试123"]).shape
# (2, 512)
# to turn off live progress bar
res = fetch_embed("test me", livepbar=False)
# brief docs
help(fetch_embed)
# fetch_embed(texts:Union[str, List[str]], endpoint:str='http://ttw.hopto.org/embed/', livepbar:bool=True) -> numpy.ndarray
Fetch embed from endpoint.
Plug in endpoint = "https://embed.ttw.workers.dev/embed_la/"
for Model 2, e.g.,
import numpy as np
from fetch_embed import fetch_embed
endpoint = "https://embed.ttw.workers.dev/embed_la/"
res = fetch_embed("test me", endpoint=endpoint)
print(np.array(res).shape)
# (1, 768)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fetch-embed-0.1.6.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for fetch_embed-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 743b183aecba22bc9bc669097a23c441310a882fbac6ca8c8a57218251030998 |
|
MD5 | 8abfe7a1565c7496285dd0141c5a951d |
|
BLAKE2b-256 | ba333a3084e6026cfad163b7a51cb9a6194afd586ad0b52273d2697bc05f9cf0 |