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.0.tar.gz
.
File metadata
- Download URL: llama_index_llms_modelscope-0.4.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6b9bb29596b7c36cc4b40ab0a9ad9cb9948b5b9b370e1426ddb285508b298e3 |
|
MD5 | ab9d06c24eff2564aa3ed4a41950b122 |
|
BLAKE2b-256 | 322fa24698d9a9bbc4f277492e78d20616f7ec9b1a718e9f5a2c0579a8781250 |
File details
Details for the file llama_index_llms_modelscope-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: llama_index_llms_modelscope-0.4.0-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.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4aad21db1a2456c1bdc062bda548c11ccbe8a441b7a68974c0e26c6fdb191f02 |
|
MD5 | 6886c690c11c43b83d4a25aa8debb04f |
|
BLAKE2b-256 | 38d3f5b2efed52df98a236385bffbe52d52ca670d87cd8ff2d367e20c89c1234 |