SpicyMelonYT commited on
Commit
19f8b29
·
1 Parent(s): 6e17d5a

added training set and path in code

Browse files
Files changed (2) hide show
  1. app.py +11 -4
  2. training_set.json +42 -0
app.py CHANGED
@@ -8,6 +8,7 @@ For more information on `huggingface_hub` Inference API support, please check th
8
  """
9
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
10
 
 
11
  def respond(
12
  message,
13
  history: list[tuple[str, str]],
@@ -40,9 +41,11 @@ def respond(
40
  response += token
41
  yield response
42
 
 
43
  def train_model():
44
  # Load dataset
45
- dataset = load_dataset('your_dataset_name')
 
46
 
47
  # Load model
48
  model = AutoModelForCausalLM.from_pretrained('meta-llama/Meta-Llama-3-8B')
@@ -68,6 +71,7 @@ def train_model():
68
  trainer.train()
69
  return "Training complete"
70
 
 
71
  """
72
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
73
  """
@@ -79,9 +83,12 @@ with demo:
79
  gr.ChatInterface(
80
  respond,
81
  additional_inputs=[
82
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
83
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
84
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
 
 
 
85
  gr.Slider(
86
  minimum=0.1,
87
  maximum=1.0,
 
8
  """
9
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
10
 
11
+
12
  def respond(
13
  message,
14
  history: list[tuple[str, str]],
 
41
  response += token
42
  yield response
43
 
44
+
45
  def train_model():
46
  # Load dataset
47
+ dataset = load_dataset('json', data_files={
48
+ 'train': 'path/to/training_set.json'})
49
 
50
  # Load model
51
  model = AutoModelForCausalLM.from_pretrained('meta-llama/Meta-Llama-3-8B')
 
71
  trainer.train()
72
  return "Training complete"
73
 
74
+
75
  """
76
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
77
  """
 
83
  gr.ChatInterface(
84
  respond,
85
  additional_inputs=[
86
+ gr.Textbox(value="You are a friendly Chatbot.",
87
+ label="System message"),
88
+ gr.Slider(minimum=1, maximum=2048, value=512,
89
+ step=1, label="Max new tokens"),
90
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7,
91
+ step=0.1, label="Temperature"),
92
  gr.Slider(
93
  minimum=0.1,
94
  maximum=1.0,
training_set.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "train": [
3
+ {
4
+ "messages": [
5
+ { "role": "system", "content": "You are a helpful assistant." },
6
+ { "role": "user", "content": "How do I train a Llama 3 model?" },
7
+ {
8
+ "role": "assistant",
9
+ "content": "To train a Llama 3 model, you need to load the dataset, define training arguments, initialize the Trainer, and start the training process. Make sure to use appropriate libraries such as Hugging Face Transformers and datasets."
10
+ }
11
+ ]
12
+ },
13
+ {
14
+ "messages": [
15
+ { "role": "system", "content": "You are a helpful assistant." },
16
+ {
17
+ "role": "user",
18
+ "content": "Can you generate text using the Llama 3 model?"
19
+ },
20
+ {
21
+ "role": "assistant",
22
+ "content": "Yes, you can generate text using the Llama 3 model by tokenizing your input text, feeding it to the model, and decoding the output. The Hugging Face Transformers library provides tools to facilitate this process."
23
+ }
24
+ ]
25
+ }
26
+ ],
27
+ "test": [
28
+ {
29
+ "messages": [
30
+ { "role": "system", "content": "You are a helpful assistant." },
31
+ {
32
+ "role": "user",
33
+ "content": "What are the main features of the Llama 3 model?"
34
+ },
35
+ {
36
+ "role": "assistant",
37
+ "content": "The main features of the Llama 3 model include its ability to generate coherent and contextually relevant responses in conversational settings, support for large-scale language understanding tasks, and compatibility with various fine-tuning and deployment tools provided by the Hugging Face ecosystem."
38
+ }
39
+ ]
40
+ }
41
+ ]
42
+ }