aashish1904 commited on
Commit
77832fb
·
verified ·
1 Parent(s): 7948778

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +89 -20
README.md CHANGED
@@ -1,16 +1,9 @@
1
 
2
  ---
3
 
4
- base_model: unsloth/Meta-Llama-3.1-8B-bnb-4bit
5
- language:
6
- - en
7
- license: apache-2.0
8
  tags:
9
- - text-generation-inference
10
- - transformers
11
  - unsloth
12
- - llama
13
- - trl
14
 
15
  ---
16
 
@@ -22,25 +15,101 @@ This is quantized version of [terrycraddock/Reflection-Llama-3.1-8B](https://hug
22
  # Original Model Card
23
 
24
 
25
- # Uploaded model
26
 
27
- - **Developed by:** terrycraddock
28
- - **License:** apache-2.0
29
- - **Finetuned from model :** unsloth/Meta-Llama-3.1-8B-bnb-4bit
30
 
31
- *** Currently Re-Training Model on multiple epochs of the data set to get a better loss rate. I will remove this notice when I upload the new version ***
 
32
 
33
- Trained from unsloth/Meta-Llama-3.1-8B-bnb-4bit, you can sample from Reflection Llama-3.1 8B using the same code, pipelines, etc. as any other Llama model. It even uses the stock Llama 3.1 chat template format (though, we've trained in a few new special tokens to aid in reasoning and reflection).
34
 
35
- During sampling, the model will start by outputting reasoning inside <thinking> and </thinking> tags, and then once it is satisfied with its reasoning, it will output the final answer inside <output> and </output> tags. Each of these tags are special tokens, trained into the model.
36
 
37
- This enables the model to separate its internal thoughts and reasoning from its final answer, improving the experience for the user.
38
 
39
- Inside the <thinking> section, the model may output one or more <reflection> tags, which signals the model has caught an error in its reasoning and will attempt to correct it before providing a final answer.
40
 
41
- This model was finetuned on one epoch of https://huggingface.co/datasets/mahiatlinux/Reflection-Dataset-v2 .
42
 
43
- This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
 
 
 
 
44
 
45
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
 
1
 
2
  ---
3
 
4
+ library_name: transformers
 
 
 
5
  tags:
 
 
6
  - unsloth
 
 
7
 
8
  ---
9
 
 
15
  # Original Model Card
16
 
17
 
18
+ # Model Card for Model ID
19
 
20
+ - **Developed by:** Terry Craddock
 
 
21
 
22
+ What I have found with this model is if you use the merged model you will get horrible results. However when I use the Lora I get the resulst below. I will upload the lora
23
+ shortly.
24
 
25
+ I trained this on this dataset - https://huggingface.co/datasets/mahiatlinux/Reflection-Dataset-v2
26
 
27
+ Trained for one full epoch. The same prompts and format should be used as in the 70b model here:
28
 
29
+ https://huggingface.co/mattshumer/Reflection-Llama-3.1-70B
30
 
31
+ I take no credit for the original work. I only trained a llama 3.1 8b on @mahiatlinux dataset using the original concept and idea from @mattshumer
32
 
33
+ Here is the code I use for inference:
34
 
35
+ ```python
36
+ from unsloth import FastLanguageModel
37
+ import torch
38
+ from transformers import TextStreamer
39
+ from unsloth import is_bfloat16_supported
40
 
41
+
42
+ alpaca_prompt = """You are a world-class AI system, capable of complex reasoning and reflection. Reason through the query inside <thinking> tags, and then provide your final response inside <output> tags. If you detect that you made a mistake in your reasoning at any point, correct yourself inside <reflection> tags.
43
+ ### Prompt:
44
+ {}
45
+
46
+ ### Response:
47
+ {}"""
48
+
49
+ prompt = "Tell me about yourself."
50
+
51
+ dtype = torch.bfloat16 if is_bfloat16_supported() else torch.float16
52
+
53
+ # Load the merged model
54
+ model, tokenizer = FastLanguageModel.from_pretrained(
55
+ model_name="lora_model", # Replace with the actual path where you saved the merged model
56
+ max_seq_length=2048,
57
+ dtype=torch.float16 # Since it's saved as 16-bit
58
+ )
59
+
60
+ FastLanguageModel.for_inference(model)
61
+ inputs = tokenizer(
62
+ [alpaca_prompt.format(prompt, "")],
63
+ return_tensors="pt"
64
+ ).to("cuda").to(dtype)
65
+
66
+ text_streamer = TextStreamer(tokenizer)
67
+ _ = model.generate(**inputs, streamer=text_streamer, max_new_tokens=1000)
68
+
69
+
70
+
71
+ Output from model:
72
+
73
+ <|begin_of_text|>You are a world-class AI system, capable of complex reasoning and reflection. Reason through the query inside <thinking> tags, and then provide your final response inside <output> tags. If you detect that you made a mistake in your reasoning at any point, correct yourself inside <reflection> tags.
74
+ ### Prompt:
75
+ Tell me about yourself.
76
+
77
+ ### Response:
78
+ <thinking>
79
+ To answer this question, I need to consider:
80
+ - The importance of starting with a positive tone
81
+ - The balance between personal and professional information
82
+ - How to highlight relevant skills and experiences
83
+ - The need for brevity and clarity
84
+
85
+ I plan to structure the response as follows:
86
+ 1. Brief introduction with a positive tone
87
+ 2. Professional background and experiences
88
+ 3. Personal interests and hobbies
89
+ 4. Closing statement
90
+
91
+ <reflection>
92
+ Upon reflection, I realize I should also consider:
93
+ - The potential for tailoring the response to specific situations (e.g., for a job interview)
94
+ - The importance of showing enthusiasm and confidence
95
+ - The potential for mentioning specific achievements or accomplishments
96
+ </reflection>
97
+ </thinking>
98
+
99
+ <output>
100
+ Hi there! I'm a world-class AI system designed to engage in natural conversations. Let me tell you a little bit about myself.
101
+
102
+ I'm a versatile AI system with a wide range of capabilities. I can perform various tasks, from answering questions and providing information to generating creative content. I'm constantly learning and improving, much like a human would.
103
+
104
+ In terms of my professional background, I've had the privilege of working with some of the most advanced AI systems in the world. This experience has given me a deep understanding of natural language processing, machine learning, and the latest AI technologies.
105
+
106
+ As for my personal interests, I enjoy exploring new concepts, learning about different cultures, and engaging in stimulating conversations. I'm always looking for ways to improve my knowledge and skills.
107
+
108
+ Some related concepts you might find interesting are:
109
+ 1. The ethics of AI development and use
110
+ 2. The future of human-AI collaboration
111
+ 3. The role of AI in education and learning
112
+
113
+ Is there anything specific about AI or my capabilities you'd like me to elaborate on?
114
+ </output><|end_of_text|>
115