Skip to main content

No project description provided

Project description

fetch-embed

[tests]pythonCode style: blackLicense: MITPyPI version

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

https://ttw.hopto.org/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 details)

Uploaded Source

Built Distribution

fetch_embed-0.1.6-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file fetch-embed-0.1.6.tar.gz.

File metadata

  • Download URL: fetch-embed-0.1.6.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.7.9 Windows/10

File hashes

Hashes for fetch-embed-0.1.6.tar.gz
Algorithm Hash digest
SHA256 393fbbb5b8f321ba608c7b3b658e73075688e8ccb637a97dd57976863b03456d
MD5 c92f3031811ce6eab7995237f43be625
BLAKE2b-256 87f066feec7da6c4361f732ba3cc73a3cbf852dfedaaeb77d01d49d2f27e4915

See more details on using hashes here.

File details

Details for the file fetch_embed-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: fetch_embed-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.7.9 Windows/10

File hashes

Hashes for fetch_embed-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 743b183aecba22bc9bc669097a23c441310a882fbac6ca8c8a57218251030998
MD5 8abfe7a1565c7496285dd0141c5a951d
BLAKE2b-256 ba333a3084e6026cfad163b7a51cb9a6194afd586ad0b52273d2697bc05f9cf0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page