NeMo
nvidia
shrimai19 commited on
Commit
5cc5562
·
verified ·
1 Parent(s): 61b43b0

Delete Mistral-NeMo-12B-Instruct-HF/run.py

Browse files
Files changed (1) hide show
  1. Mistral-NeMo-12B-Instruct-HF/run.py +0 -32
Mistral-NeMo-12B-Instruct-HF/run.py DELETED
@@ -1,32 +0,0 @@
1
- from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
2
- from mistral_common.protocol.instruct.messages import UserMessage
3
- from mistral_common.protocol.instruct.request import ChatCompletionRequest
4
- from transformers import AutoModelForCausalLM
5
- import torch
6
-
7
-
8
- # Load Mistral tokenizer
9
- model_name = "nemostral"
10
- tokenizer = MistralTokenizer.from_model(model_name)
11
-
12
- # Tokenize a list of messages
13
- tokenized = tokenizer.encode_chat_completion(
14
- ChatCompletionRequest(
15
- messages=[
16
- UserMessage(content="How many peolpe live in France and all its neighbours? List all of them!")
17
- ],
18
- model=model_name,
19
- )
20
- )
21
- tokens, text = tokenized.tokens, tokenized.text
22
-
23
- input_ids = torch.tensor([tokens]).to("cuda")
24
-
25
- model = AutoModelForCausalLM.from_pretrained("./", torch_dtype=torch.bfloat16).to("cuda")
26
-
27
-
28
- out = model.generate(input_ids, max_new_tokens=1024)
29
-
30
- generated = out[0, input_ids.shape[-1]:-1].tolist()
31
-
32
- print(tokenizer.decode(generated))