llmlite
A library helps to communicate with all kinds of LLMs consistently.
| Model | State | System Prompt | Note |
|---|---|---|---|
| ChatGPT | Done ✅ | Yes | |
| Llama-2 | Done ✅ | Yes | |
| CodeLlama | Done ✅ | Yes | |
| ChatGLM2 | Done ✅ | No | |
| ChatGLM3 | WIP ⏳ | Yes | |
| Baichuan2 | Done ✅ | Yes | |
| Claude-2 | RoadMap 📋 | issue#7 | |
| Falcon | RoadMap 📋 | issue#8 | |
| StableLM | RoadMap 📋 | issue#11 | |
| Baichuan2 | RoadMap 📋 | issue#34 | |
| ... | ... | ... | ... |
llmlite also supports different inference backends as below:
| backend | State | Note |
|---|---|---|
| huggingface | Done ✅ | Support by huggingface pipeline |
| vLLM | Done ✅ | |
| ... | ... | ... |
How to install
pip install llmlite==0.0.9
How to use
Chat
from llmlite.apis import ChatLLM, ChatMessage
chat = ChatLLM(
model_name_or_path="meta-llama/Llama-2-7b-chat-hf", # required
task="text-generation",
backend="vllm",
)
result = chat.completion(
messages=[
ChatMessage(role="system", content="You're a honest assistant."),
ChatMessage(role="user", content="There's a llama in my garden, what should I do?"),
]
)
# Output: Oh my goodness, a llama in your garden?! 😱 That's quite a surprise! 😅 As an honest assistant, I must inform you that llamas are not typically known for their gardening skills, so it's possible that the llama in your garden may have wandered there accidentally or is seeking shelter. 🐮 ...
llmlite also supports other parameters like temperature, max_length, do_sample, top_k, top_p to help control the length, randomness and diversity of the generated text.
See examples for reference.
Prompting
You can use llmlite to help you generate full prompts, for instance:
from llmlite.apis import ChatMessage, LlamaChat
messages = [
ChatMessage(role="system", content="You're a honest assistant."),
ChatMessage(role="user", content="There's a llama in my garden, what should I do?"),
]
LlamaChat.prompt(messages)
# Output:
# <s>[INST] <<SYS>>
# You're a honest assistant.
# <</SYS>>
# There's a llama in my garden, what should I do? [/INST]
Logging
Set the env variable LOG_LEVEL for log configuration, default to INFO, others like DEBUG, INFO, WARNING etc..
Roadmap
- Adapter support
- Quantization
- Streaming
Contributions
🚀 All kinds of contributions are welcomed ! Please follow Contributing.
Contributors
🎉 Thanks to all these contributors.
Release files for llmlite 0.0.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| llmlite-0.0.15.tar.gz | 11.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llmlite-0.0.15-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.1 kB
Release files / llmlite-0.0.15.tar.gz
| Download URL | llmlite-0.0.15.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47edb0fdb9ef363a455692b2e0402ebe82168c2ab545a7178474a2c907263b84
|
|
BLAKE2b-256 checksum How to use checksums |
289d661ab6212e8e454738bb539a63f01a91cdc2ec84e6746b591ecee24aa718
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.13 Darwin/20.4.0
|
Release files / llmlite-0.0.15-py3-none-any.whl
| Download URL | llmlite-0.0.15-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f559824a957b0cbf4922ef7a460fc7d6dd841a53b07ac8c8211ad25a8bb0bdc0
|
|
BLAKE2b-256 checksum How to use checksums |
280a5ac631e71d2a1ff4347f52d0f3054e532785491baae6c5135d545dce6840
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.10.13 Darwin/20.4.0
|