AINovice2005
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -15,34 +15,33 @@ tags:
|
|
15 |
|
16 |
ElEmperador is an ORPO finetinue derived from the Mistral-7B-v0.1 base model.
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
def generate_response(model_name, input_text, max_new_tokens=50):
|
21 |
-
|
22 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
23 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
24 |
|
25 |
-
|
26 |
input_ids = tokenizer(input_text, return_tensors='pt').input_ids
|
27 |
|
28 |
-
|
29 |
with torch.no_grad():
|
30 |
generated_ids = model.generate(input_ids, max_new_tokens=max_new_tokens)
|
31 |
|
32 |
-
|
33 |
generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
|
34 |
|
35 |
return generated_text
|
36 |
|
37 |
-
if __name__ == "__main__":
|
38 |
# Set the model name from Hugging Face Hub
|
39 |
-
model_name = "AINovice2005/ElEmperador"
|
40 |
input_text = "Hello, how are you?"
|
41 |
|
42 |
-
|
43 |
output = generate_response(model_name, input_text)
|
44 |
|
45 |
-
|
46 |
print(f"Input: {input_text}")
|
47 |
print(f"Output: {output}")
|
48 |
-
|
|
|
15 |
|
16 |
ElEmperador is an ORPO finetinue derived from the Mistral-7B-v0.1 base model.
|
17 |
|
18 |
+
Inference Script:
|
19 |
+
|
20 |
+
- def generate_response(model_name, input_text, max_new_tokens=50):
|
21 |
+
# Load the tokenizer and model from Hugging Face Hub
|
22 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
23 |
model = AutoModelForCausalLM.from_pretrained(model_name)
|
24 |
|
25 |
+
# Tokenize the input text
|
26 |
input_ids = tokenizer(input_text, return_tensors='pt').input_ids
|
27 |
|
28 |
+
# Generate a response using the model
|
29 |
with torch.no_grad():
|
30 |
generated_ids = model.generate(input_ids, max_new_tokens=max_new_tokens)
|
31 |
|
32 |
+
# Decode the generated tokens into text
|
33 |
generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
|
34 |
|
35 |
return generated_text
|
36 |
|
37 |
+
- if __name__ == "__main__":
|
38 |
# Set the model name from Hugging Face Hub
|
39 |
+
model_name = "AINovice2005/ElEmperador"
|
40 |
input_text = "Hello, how are you?"
|
41 |
|
42 |
+
# Generate and print the model's response
|
43 |
output = generate_response(model_name, input_text)
|
44 |
|
|
|
45 |
print(f"Input: {input_text}")
|
46 |
print(f"Output: {output}")
|
47 |
+
|