macadeliccc commited on
Commit
d70f7c9
1 Parent(s): 30d58ac

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +1 -10
README.md CHANGED
@@ -27,33 +27,24 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
27
  def generate_response(prompt):
28
  """
29
  Generate a response from the model based on the input prompt.
30
-
31
  Args:
32
  prompt (str): Prompt for the model.
33
-
34
  Returns:
35
  str: The generated response from the model.
36
  """
37
- # Tokenize the input prompt
38
  inputs = tokenizer(prompt, return_tensors="pt")
39
-
40
- # Generate output tokens
41
  outputs = model.generate(**inputs, max_new_tokens=512, eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.pad_token_id)
42
-
43
- # Decode the generated tokens to a string
44
  response = tokenizer.decode(outputs[0], skip_special_tokens=True)
45
 
46
  return response
47
 
48
-
49
- # Load the model and tokenizer
50
  model_id = "macadeliccc/SOLAR-math-2x10.7b"
51
  tokenizer = AutoTokenizer.from_pretrained(model_id)
52
  model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True)
53
 
54
  prompt = "Explain the proof of Fermat's Last Theorem and its implications in number theory."
55
 
56
-
57
  print("Response:")
58
  print(generate_response(prompt), "\n")
59
  ```
 
27
  def generate_response(prompt):
28
  """
29
  Generate a response from the model based on the input prompt.
 
30
  Args:
31
  prompt (str): Prompt for the model.
 
32
  Returns:
33
  str: The generated response from the model.
34
  """
35
+
36
  inputs = tokenizer(prompt, return_tensors="pt")
 
 
37
  outputs = model.generate(**inputs, max_new_tokens=512, eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.pad_token_id)
 
 
38
  response = tokenizer.decode(outputs[0], skip_special_tokens=True)
39
 
40
  return response
41
 
 
 
42
  model_id = "macadeliccc/SOLAR-math-2x10.7b"
43
  tokenizer = AutoTokenizer.from_pretrained(model_id)
44
  model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True)
45
 
46
  prompt = "Explain the proof of Fermat's Last Theorem and its implications in number theory."
47
 
 
48
  print("Response:")
49
  print(generate_response(prompt), "\n")
50
  ```