https://github.com/bentoml/bentosentencetransformers

how to build a sentence embedding application using BentoML

https://github.com/bentoml/bentosentencetransformers

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

how to build a sentence embedding application using BentoML

Basic Info
  • Host: GitHub
  • Owner: bentoml
  • Language: Python
  • Default Branch: main
  • Size: 28.3 KB
Statistics
  • Stars: 13
  • Watchers: 5
  • Forks: 2
  • Open Issues: 1
  • Releases: 0
Created over 2 years ago · Last pushed over 1 year ago
Metadata Files
Readme

README.md

Serving SentenceTransformers with BentoML

SentenceTransformers is a Python framework for state-of-the-art sentence, text and image embeddings.

This is a BentoML example project, demonstrating how to build a sentence embedding inference API server, using a SentenceTransformers model all-MiniLM-L6-v2. See here for a full list of BentoML example projects.

Install dependencies

```bash git clone https://github.com/bentoml/BentoSentenceTransformers.git cd BentoSentenceTransformers

Recommend Python 3.11

pip install -r requirements.txt ```

Run the BentoML Service

We have defined a BentoML Service in service.py. Run bentoml serve in your project directory to start the Service.

```bash $ bentoml serve .

2024-01-18T06:40:53+0800 [INFO] [cli] Prometheus metrics for HTTP BentoServer from "service:SentenceEmbedding" can be accessed at http://localhost:3000/metrics. 2024-01-18T06:40:54+0800 [INFO] [cli] Starting production HTTP BentoServer from "service:SentenceEmbedding" listening on http://localhost:3000 (Press CTRL+C to quit) Model loaded device: cpu ```

The server is now active at http://localhost:3000. You can interact with it using the Swagger UI or in other different ways.

CURL

bash curl -X 'POST' \ 'http://localhost:3000/encode' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "sentences": [ "hello world" ] }'

Python client

```python import bentoml

with bentoml.SyncHTTPClient("http://localhost:3000") as client: result = client.encode( sentences=[ "hello world" ], ) ```

For detailed explanations of the Service code, see Sentence Transformer.

Deploy to BentoCloud

After the Service is ready, you can deploy the application to BentoCloud for better management and scalability. Sign up if you haven't got a BentoCloud account.

Make sure you have logged in to BentoCloud, then run the following command to deploy it.

bash bentoml deploy .

Once the application is up and running on BentoCloud, you can access it via the exposed URL.

Note: For custom deployment in your own infrastructure, use BentoML to generate an OCI-compliant image.

Owner

  • Name: BentoML
  • Login: bentoml
  • Kind: organization
  • Location: San Francisco

The most flexible way to serve AI models in production

GitHub Events

Total
  • Watch event: 5
  • Delete event: 2
  • Push event: 2
  • Pull request review event: 2
  • Pull request event: 5
  • Create event: 1
Last Year
  • Watch event: 5
  • Delete event: 2
  • Push event: 2
  • Pull request review event: 2
  • Pull request event: 5
  • Create event: 1

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 14
  • Average time to close issues: N/A
  • Average time to close pull requests: 20 days
  • Total issue authors: 0
  • Total pull request authors: 5
  • Average comments per issue: 0
  • Average comments per pull request: 0.07
  • Merged pull requests: 11
  • Bot issues: 0
  • Bot pull requests: 2
Past Year
  • Issues: 0
  • Pull requests: 6
  • Average time to close issues: N/A
  • Average time to close pull requests: about 14 hours
  • Issue authors: 0
  • Pull request authors: 3
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • Sherlock113 (10)
  • ssheng (4)
  • parano (4)
  • bojiang (4)
  • dependabot[bot] (3)
Top Labels
Issue Labels
Pull Request Labels
documentation (4) dependencies (3)

Dependencies

requirements.txt pypi
  • bentoml >=1.2.0rc1
  • sentence-transformers ==2.2.2
  • sentencepiece ==0.1.99
  • torch ==2.1.2
  • transformers ==4.37.1
  • triton ==2.1.0