lvkaokao commited on
Commit
af2489c
1 Parent(s): 12ae430

update example.

Browse files
Files changed (1) hide show
  1. README.md +21 -5
README.md CHANGED
@@ -63,14 +63,13 @@ model_name = 'Intel/neural-chat-7b-v3-1'
63
  model = transformers.AutoModelForCausalLM.from_pretrained(model_name)
64
  tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
65
 
66
-
67
  def generate_response(system_input, user_input):
68
-
69
  # Format the input using the provided template
70
  prompt = f"### System:\n{system_input}\n### User:\n{user_input}\n### Assistant:\n"
71
 
72
  # Tokenize and encode the prompt
73
- inputs = tokenizer.encode(prompt, return_tensors="pt")
74
 
75
  # Generate a response
76
  outputs = model.generate(inputs, max_length=1000, num_return_sequences=1)
@@ -81,10 +80,27 @@ def generate_response(system_input, user_input):
81
 
82
 
83
  # Example usage
84
- system_input = "You are a chatbot developed by Intel. Please answer all questions to the best of your ability."
85
- user_input = "How does the neural-chat-7b-v3-1 model work?"
86
  response = generate_response(system_input, user_input)
87
  print(response)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  ```
89
 
90
  ## Ethical Considerations and Limitations
 
63
  model = transformers.AutoModelForCausalLM.from_pretrained(model_name)
64
  tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
65
 
 
66
  def generate_response(system_input, user_input):
67
+
68
  # Format the input using the provided template
69
  prompt = f"### System:\n{system_input}\n### User:\n{user_input}\n### Assistant:\n"
70
 
71
  # Tokenize and encode the prompt
72
+ inputs = tokenizer.encode(prompt, return_tensors="pt", add_special_tokens=False)
73
 
74
  # Generate a response
75
  outputs = model.generate(inputs, max_length=1000, num_return_sequences=1)
 
80
 
81
 
82
  # Example usage
83
+ system_input = "You are a math expert assistant. Your mission is to help users understand and solve various math problems. You should provide step-by-step solutions, explain reasonings and give the correct answer."
84
+ user_input = "calculate 100 + 520 + 60"
85
  response = generate_response(system_input, user_input)
86
  print(response)
87
+
88
+ # expected response
89
+ """
90
+ To calculate the sum of 100, 520, and 60, we will follow these steps:
91
+
92
+ 1. Add the first two numbers: 100 + 520
93
+ 2. Add the result from step 1 to the third number: (100 + 520) + 60
94
+
95
+ Step 1: Add 100 and 520
96
+ 100 + 520 = 620
97
+
98
+ Step 2: Add the result from step 1 to the third number (60)
99
+ (620) + 60 = 680
100
+
101
+ So, the sum of 100, 520, and 60 is 680.
102
+ """
103
+
104
  ```
105
 
106
  ## Ethical Considerations and Limitations