LH-Tech-AI commited on
Commit
571dc68
Β·
verified Β·
1 Parent(s): 414c778

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +142 -0
README.md CHANGED
@@ -1,3 +1,145 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ datasets:
4
+ - HuggingFaceFW/fineweb-edu
5
+ language:
6
+ - en
7
+ pipeline_tag: text-generation
8
+ library_name: transformers
9
+ tags:
10
+ - supra
11
+ - chimera
12
+ - 50m
13
+ - llama
14
+ - small
15
+ - open
16
+ - open-source
17
+ - cpu
18
+ - tiny
19
+ - slm
20
  ---
21
+
22
+ # πŸ¦… Supra-50M Instruct
23
+
24
+ **Supra-50M Instruct** is a compact 50M-parameter chat/instruct causal language model built by SupraLabs, trained from scratch using a Llama-style architecture on 20 billion tokens of high-quality educational web text. Despite being significantly smaller than comparable open models, it achieves competitive or superior results on several key benchmarks. It's our first SupraLabs Scaling Up Plan model.
25
+
26
+ ---
27
+
28
+ ## πŸ“š Training Data
29
+
30
+ For the SFT (supervised finetuning) we used the full Alpaca-Cleaned dataset for 4 epochs. See the full SFT-code in sft.py
31
+
32
+ ---
33
+
34
+ ## βš™οΈ Pretraining details
35
+ For more details, the full code, configs and weights, please refer to [https://huggingface.co/SupraLabs/Supra-50M-Base](https://huggingface.co/SupraLabs/Supra-50M-Base)
36
+
37
+ ---
38
+
39
+ ## πŸš€ Inference
40
+
41
+ ```python
42
+ import torch
43
+ from transformers import pipeline, AutoTokenizer
44
+
45
+ # ── Config ────────────────────────────────────────────────────────────────────
46
+
47
+ MODEL_ID = "SupraLabs/Supra-50M-Instruct/"
48
+ MAX_NEW_TOKENS = 512
49
+
50
+ # ── Load pipeline directly from HF ────────────────────────────────────────────
51
+
52
+ print(f"[*] Loading SFT model and tokenizer from HF Hub ({MODEL_ID})...")
53
+
54
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
55
+
56
+ pipe = pipeline(
57
+ "text-generation",
58
+ model=MODEL_ID,
59
+ tokenizer=tokenizer,
60
+ device_map="auto",
61
+ torch_dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32
62
+ )
63
+
64
+ print(f"[+] Pipeline ready β€” Model loaded using {pipe.model.device}")
65
+
66
+ # ── Prompt template (must match sft.py exactly) ───────────────────────────────
67
+
68
+ def build_prompt(instruction: str, input_text: str = "") -> str:
69
+ if input_text.strip():
70
+ return (
71
+ "Below is an instruction that describes a task, paired with an input "
72
+ "that provides further context. Write a response that appropriately "
73
+ "completes the request.\n\n"
74
+ f"### Instruction:\n{instruction}\n\n"
75
+ f"### Input:\n{input_text}\n\n"
76
+ "### Response:\n"
77
+ )
78
+ return (
79
+ "Below is an instruction that describes a task. Write a response that "
80
+ "appropriately completes the request.\n\n"
81
+ f"### Instruction:\n{instruction}\n\n"
82
+ "### Response:\n"
83
+ )
84
+
85
+ # ── Generate ──────────────────────────────────────────────────────────────────
86
+
87
+ def generate(instruction: str, input_text: str = "", max_new_tokens: int = MAX_NEW_TOKENS) -> str:
88
+ prompt = build_prompt(instruction, input_text)
89
+
90
+ result = pipe(
91
+ prompt,
92
+ max_new_tokens=max_new_tokens,
93
+ do_sample=True,
94
+ temperature=0.7,
95
+ top_k=50,
96
+ top_p=0.9,
97
+ repetition_penalty=1.15,
98
+ pad_token_id=pipe.tokenizer.pad_token_id,
99
+ eos_token_id=pipe.tokenizer.eos_token_id,
100
+ return_full_text=False
101
+ )
102
+
103
+ return result[0]['generated_text'].strip()
104
+
105
+ # ── Interactive loop ──────────────────────────────────────────────────────────
106
+
107
+ if __name__ == "__main__":
108
+ print("\n[+] Ready. Type 'quit' to exit.\n")
109
+
110
+ while True:
111
+ instruction = input("Instruction: ").strip()
112
+ if instruction.lower() == "quit":
113
+ break
114
+
115
+ inp = input("Input (optional, Enter to skip): ").strip()
116
+
117
+ print("-" * 50)
118
+ print(generate(instruction, inp))
119
+ print()
120
+ ```
121
+
122
+ ---
123
+
124
+ ## πŸ’¬ Sample Outputs
125
+
126
+ **User:** What is AI?<br>
127
+ **Supra-50M Instruct:**:<br>
128
+ AI refers to the simulation of human intelligence and creativity in machines, which are designed to mimic or surpass human cognition and reasoning. It is the process by which AI systems can solve problems, make predictions, or automate processes that typically require human-level thinking and problem solving. AI technology has been rapidly growing and evolving over time, with many potential benefits for society as a whole. Some of these include:
129
+ 1. Improved Accuracy: AI algorithms have demonstrated great accuracy in predicting outcomes, making accurate predictions on new data sets, and even answering real-world questions. This improves our ability to learn from experience and adapt to changing situations.
130
+ 2. Personalization: AI is used to personalize user experiences, such as recommending products based on their previous interactions and preferences. This helps people to stay motivated and maintain high levels of satisfaction.
131
+ 3. Better Decision Making: AI enables systems to analyze large amounts of data quickly and accurately, allowing us to make informed decisions more easily and
132
+
133
+ <br>
134
+
135
+ See samples.txt for more!
136
+
137
+ ---
138
+
139
+ ## πŸ“„ License
140
+
141
+ This model is released under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0).
142
+
143
+ ---
144
+
145
+ *Β© SupraLabs 2026 β€” Project Chimera*