https://github.com/bentoml/bentolmdeploy
Self-host LLMs with LMDeploy and BentoML
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 (14.0%) to scientific vocabulary
Repository
Self-host LLMs with LMDeploy and BentoML
Basic Info
- Host: GitHub
- Owner: bentoml
- Language: Python
- Default Branch: main
- Size: 43.9 KB
Statistics
- Stars: 22
- Watchers: 4
- Forks: 2
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
Self-host LLMs with LMDeploy and BentoML
This is a BentoML example project, showing you how to serve and deploy open-source Large Language Models (LLMs) using LMDeploy, a toolkit for compressing, deploying, and serving LLMs.
See here for a full list of BentoML example projects.
💡 This example is served as a basis for advanced code customization, such as custom model, inference logic or LMDeploy options. For simple LLM hosting with OpenAI compatible endpoint without writing any code, see OpenLLM.
Prerequisites
- You have installed Python 3.8+ and
pip. See the Python downloads page to learn more. - You have a basic understanding of key concepts in BentoML, such as Services. We recommend you read Quickstart first.
- If you want to test the Service locally, you need a Nvidia GPU with at least 20G VRAM.
- This example uses Llama 3 8B Instruct. Make sure you have gained access to the model.
- (Optional) We recommend you create a virtual environment for dependency isolation for this project. See the Conda documentation or the Python documentation for details.
Install dependencies
bash
git clone https://github.com/bentoml/BentoLMDeploy.git
cd BentoLMDeploy/llama3.1-8b-instruct
pip install -r requirements.txt
Download the model
Run the script to download Llama 3.
bash
python import_model.py
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-05-04T17:24:01+0800 [INFO] [cli] Starting production HTTP BentoServer from "service:LMDeploy" listening on http://localhost:3000 (Press CTRL+C to quit) 2024-05-04 17:24:03,239 - lmdeploy - INFO - input backend=turbomind, backendconfig=TurbomindEngineConfig(modelname='meta-llama/Meta-Llama-3-8B-Instruct', modelformat='hf', tp=1, sessionlen=None, maxbatchsize=128, cach emaxentrycount=0.9, cacheblockseqlen=64, quantpolicy=0, ropescalingfactor=0.0, uselognattn=False, downloaddir=None, revision=None, maxprefilltokennum=8192, numtokensperiter=0, maxprefilliters=1) 2024-05-04 17:24:03,240 - lmdeploy - INFO - input chattemplateconfig=None 2024-05-04 17:24:03,339 - lmdeploy - INFO - updated chattemplateonfig=ChatTemplateConfig(modelname='llama3', system=None, metainstruction=None, eosys=None, user=None, eoh=None, assistant=None, eoa=None, separator=None, capability=None, stopwords=None) 2024-05-04 17:24:03,359 - lmdeploy - WARNING - modelsource: hfmodel 2024-05-04 17:24:03,359 - lmdeploy - WARNING - modelname is deprecated in TurbomindEngineConfig and has no effect Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained. Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained. 2024-05-04 17:24:03,727 - lmdeploy - WARNING - model_config:
... ```
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/generate' \ -H 'accept: text/event-stream' \ -H 'Content-Type: application/json' \ -d '{ "prompt": "Explain superconductors like I'\''m five years old", "max_tokens": 1024 }' ```Python client
```python import bentoml with bentoml.SyncHTTPClient("http://localhost:3000") as client: response_generator = client.generate( prompt="Explain superconductors like I'm five years old", max_tokens=1024 ) for response in response_generator: print(response, end='') ```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
- Website: https://bentoml.com
- Twitter: bentomlai
- Repositories: 76
- Profile: https://github.com/bentoml
The most flexible way to serve AI models in production
GitHub Events
Total
- Watch event: 6
- Push event: 5
- Pull request review event: 1
- Pull request event: 2
Last Year
- Watch event: 6
- Push event: 5
- Pull request review event: 1
- Pull request event: 2
Issues and Pull Requests
Last synced: over 1 year ago
All Time
- Total issues: 1
- Total pull requests: 5
- Average time to close issues: N/A
- Average time to close pull requests: about 7 hours
- Total issue authors: 1
- Total pull request authors: 3
- Average comments per issue: 0.0
- Average comments per pull request: 0.4
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 5
- Average time to close issues: N/A
- Average time to close pull requests: about 7 hours
- Issue authors: 1
- Pull request authors: 3
- Average comments per issue: 0.0
- Average comments per pull request: 0.4
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- JasonFuuuuuuuu (1)
Pull Request Authors
- larme (4)
- Sherlock113 (2)
- zhyncs (2)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- accelerate ==0.29.3
- bentoml >=1.2.11
- lmdeploy ==0.4.0
- packaging ==24.0
- torch ==2.2.2
- transformers ==4.40.1