llama-index llms modelscope integration
Project description
LlamaIndex Llms Integration: ModelScope
Installation
To install the required package, run:
!pip install llama-index-llms-modelscope
Basic Usage
Initialize the ModelScopeLLM
To use the ModelScopeLLM model, create an instance by specifying the model name and revision:
import sys
from llama_index.llms.modelscope import ModelScopeLLM
llm = ModelScopeLLM(model_name="qwen/Qwen1.5-7B-Chat", model_revision="master")
Generate Completions
To generate a text completion for a prompt, use the complete
method:
rsp = llm.complete("Hello, who are you?")
print(rsp)
Using Message Requests
You can chat with the model by using a list of messages. Here’s how to set it up:
from llama_index.core.base.llms.types import MessageRole, ChatMessage
messages = [
ChatMessage(
role=MessageRole.SYSTEM, content="You are a helpful assistant."
),
ChatMessage(role=MessageRole.USER, content="How to make cake?"),
]
resp = llm.chat(messages)
print(resp)
LLM Implementation example
https://docs.llamaindex.ai/en/stable/examples/llm/modelscope/
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
Built Distribution
File details
Details for the file llama_index_llms_modelscope-0.4.1.tar.gz
.
File metadata
- Download URL: llama_index_llms_modelscope-0.4.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 264153d0dccf7a240b21328c2efd39c2d2a5de1729dc80979788c1ba1cd99f75 |
|
MD5 | 80a6bb3c4b1e8c6d9d58f6f8e1aba1d6 |
|
BLAKE2b-256 | 16a4ce218bb6ee700fa77cc95391c4f46957e3d58b098f7c32899136feed4b1f |
File details
Details for the file llama_index_llms_modelscope-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: llama_index_llms_modelscope-0.4.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a804516307d26260a026af3131648c195b49db01d7a4fb4a138afad1a3f36c3 |
|
MD5 | 9b0fb765ffb6a4c7d03c869aa59d19de |
|
BLAKE2b-256 | af279db31fb1f4dfb0079257f290fd1d74db4b36d7757f392abf1676cbd83ac0 |