macadeliccc commited on
Commit
add8a48
1 Parent(s): 3995e9a

Added demo code according to the prompt format

Browse files

model response from this code:

The neural-chat-7b-v3-1 model is a language model developed by OpenAI. It is a large-scale, multilingual, and highly capable model that can generate human-like text. It is based on the GPT-3 architecture and has been trained on a vast amount of text data, including books, articles, and web pages.

The model works by using deep learning techniques to analyze and understand the context of the given input text. It then generates an output text that is relevant and coherent with the input, while also maintaining a natural language flow. The neural-chat-7b-v3-1 model is designed to be versatile and can be used for various tasks such as conversation, text completion, and text generation.

In summary, the neural-chat-7b-v3-1 model works by learning from a massive amount of text data and using advanced deep learning algorithms to generate human-like responses based on the input text.

Files changed (1) hide show
  1. README.md +29 -4
README.md CHANGED
@@ -52,11 +52,36 @@ The following hyperparameters were used during training:
52
 
53
  ## Inference with transformers
54
 
55
- ```shell
56
  import transformers
57
- model = transformers.AutoModelForCausalLM.from_pretrained(
58
- 'Intel/neural-chat-7b-v3-1'
59
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  ```
61
 
62
  ## Ethical Considerations and Limitations
 
52
 
53
  ## Inference with transformers
54
 
55
+ ```python
56
  import transformers
57
+
58
+
59
+ model_name = 'Intel/neural-chat-7b-v3-1'
60
+ model = transformers.AutoModelForCausalLM.from_pretrained(model_name)
61
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
62
+
63
+
64
+ def generate_response(system_input, user_input):
65
+
66
+ # Format the input using the provided template
67
+ prompt = f"### System:\n{system_input}\n### User:\n{user_input}\n### Assistant:\n"
68
+
69
+ # Tokenize and encode the prompt
70
+ inputs = tokenizer.encode(prompt, return_tensors="pt")
71
+
72
+ # Generate a response
73
+ outputs = model.generate(inputs, max_length=1000, num_return_sequences=1)
74
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
75
+
76
+ # Extract only the assistant's response
77
+ return response.split("### Assistant:\n")[-1]
78
+
79
+
80
+ # Example usage
81
+ system_input = "You are a chatbot developed by Intel. Please answer all questions to the best of your ability."
82
+ user_input = "How does the neural-chat-7b-v3-1 model work?"
83
+ response = generate_response(system_input, user_input)
84
+ print(response)
85
  ```
86
 
87
  ## Ethical Considerations and Limitations