Update README.md
Browse files
README.md
CHANGED
|
@@ -322,13 +322,16 @@ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
|
|
| 322 |
from mistral_common.protocol.instruct.messages import UserMessage, TextChunk, ImageURLChunk
|
| 323 |
from mistral_common.protocol.instruct.request import ChatCompletionRequest
|
| 324 |
|
| 325 |
-
tokenizer = MistralTokenizer.
|
| 326 |
model = Transformer.from_folder(mistral_models_path)
|
| 327 |
|
| 328 |
url = "https://huggingface.co/datasets/patrickvonplaten/random_img/resolve/main/yosemite.png"
|
| 329 |
prompt = "Describe the image."
|
| 330 |
|
| 331 |
-
completion_request = ChatCompletionRequest(messages=[
|
|
|
|
|
|
|
|
|
|
| 332 |
|
| 333 |
encoded = tokenizer.encode_chat_completion(completion_request)
|
| 334 |
|
|
|
|
| 322 |
from mistral_common.protocol.instruct.messages import UserMessage, TextChunk, ImageURLChunk
|
| 323 |
from mistral_common.protocol.instruct.request import ChatCompletionRequest
|
| 324 |
|
| 325 |
+
tokenizer = MistralTokenizer.v7().instruct_tokenizer
|
| 326 |
model = Transformer.from_folder(mistral_models_path)
|
| 327 |
|
| 328 |
url = "https://huggingface.co/datasets/patrickvonplaten/random_img/resolve/main/yosemite.png"
|
| 329 |
prompt = "Describe the image."
|
| 330 |
|
| 331 |
+
completion_request = ChatCompletionRequest(messages=[
|
| 332 |
+
SystemMessage(content=SYSTEM_PROMPT)
|
| 333 |
+
UserMessage(content=[ImageURLChunk(image_url=url), TextChunk(text=prompt)])
|
| 334 |
+
])
|
| 335 |
|
| 336 |
encoded = tokenizer.encode_chat_completion(completion_request)
|
| 337 |
|