BrainboxAI commited on
Commit
a9da9d6
verified
1 Parent(s): 599f2b9

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +40 -7
  2. app.py +88 -0
  3. requirements.txt +7 -0
README.md CHANGED
@@ -1,12 +1,45 @@
1
  ---
2
- title: Code Il E4B
3
- emoji: 馃弳
4
- colorFrom: gray
5
- colorTo: blue
6
  sdk: gradio
7
- sdk_version: 6.13.0
8
  app_file: app.py
9
- pinned: false
 
 
 
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: code-il-E4B
3
+ emoji: 馃捇
4
+ colorFrom: blue
5
+ colorTo: indigo
6
  sdk: gradio
7
+ sdk_version: 4.44.0
8
  app_file: app.py
9
+ pinned: true
10
+ license: apache-2.0
11
+ short_description: Israeli code model 4B - Gemma 4 + NVIDIA OpenCodeInstruct
12
+ models:
13
+ - BrainboxAI/code-il-E4B-safetensors
14
  ---
15
 
16
+ # code-il-E4B
17
+
18
+ 诪讜讚诇 拽讜讚 讬砖专讗诇讬 讘讙讜讚诇 4 诪讬诇讬讗专讚 驻专诪讟专讬诐. 专抓 注诇 诪讞砖讘 谞讬讬讚, 转讜诪讱 讘注讘专讬转, 诪转诪讞讛 讘-Python 讜-TypeScript.
19
+
20
+ ## 诪讛 诪讬讜讞讚 讘讜
21
+
22
+ - **讘住讬住**: Gemma 4 E4B 砖诇 Google
23
+ - **fine-tuning**: 注诇 dataset 砖诇 5 诪讬诇讬讜谉 讚讜讙诪讗讜转 拽讜讚 诪-NVIDIA + 40K 讚讜讙诪讗讜转 注讘专讬讜转 砖讗住驻转讬
24
+ - **专抓 on-device**: 4B 驻专诪讟专讬诐 谞讻谞住讬诐 讘讝讬讻专讜谉 砖诇 诪讞砖讘 谞讬讬讚 专讙讬诇
25
+ - **讚讜-诇砖讜谞讬**: 转讜诪讱 讘拽讜讚 讘讗谞讙诇讬转 讜讛住讘专讬诐 讘注讘专讬转
26
+
27
+ ## 讗讬讱 诪专讬爪讬诐 诪拽讜诪讬转
28
+
29
+ ```python
30
+ from transformers import AutoTokenizer, AutoModelForCausalLM
31
+
32
+ tokenizer = AutoTokenizer.from_pretrained("BrainboxAI/code-il-E4B-safetensors")
33
+ model = AutoModelForCausalLM.from_pretrained(
34
+ "BrainboxAI/code-il-E4B-safetensors",
35
+ torch_dtype="auto",
36
+ device_map="auto",
37
+ )
38
+ ```
39
+
40
+ ## 谞讘谞讛 注诇 讬讚讬
41
+
42
+ [BrainboxAI](https://huggingface.co/BrainboxAI) - 讞讘专转 AI 讬砖专讗诇讬转 砖讘讜谞讛 诪讜讚诇讬诐 讬砖专讗诇讬讬诐 诇转注砖讬讬讛.
43
+ 诪讜讚诇讬诐 谞讜住驻讬诐: [law-il-E2B](https://huggingface.co/BrainboxAI/law-il-E2B) (诪砖驻讟讬), [med-il-E4B](https://huggingface.co/BrainboxAI/med-il-E4B) (专驻讜讗讬).
44
+
45
+ Built with [Unsloth](https://unsloth.ai) for 2x faster training.
app.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import spaces
3
+ import torch
4
+ from transformers import AutoTokenizer, AutoModelForCausalLM, TextIteratorStreamer
5
+ from threading import Thread
6
+
7
+ MODEL_ID = "BrainboxAI/code-il-E4B-safetensors"
8
+
9
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
10
+ model = AutoModelForCausalLM.from_pretrained(
11
+ MODEL_ID,
12
+ torch_dtype=torch.bfloat16,
13
+ device_map="auto",
14
+ )
15
+
16
+ EXAMPLES = [
17
+ ["Implement binary search in TypeScript with full edge case handling and JSDoc comments."],
18
+ ["Build a FastAPI endpoint that accepts a file upload, validates it's a PDF under 10MB, and returns its text content."],
19
+ ["Write an n8n Code node (JavaScript) that takes input items, deduplicates by 'email' field, and returns the unique ones."],
20
+ ["讛住讘专 讗转 讛拽讜讚 讛讘讗 讜转爪讬注 砖讬驻讜专讬诐:\n\nfunction calc(arr) {\n let s = 0;\n for (let i = 0; i < arr.length; i++) s += arr[i];\n return s / arr.length;\n}"],
21
+ ]
22
+
23
+
24
+ @spaces.GPU(duration=60)
25
+ def generate(message, history, temperature, max_tokens):
26
+ messages = []
27
+ for user_msg, assistant_msg in history:
28
+ messages.append({"role": "user", "content": user_msg})
29
+ if assistant_msg:
30
+ messages.append({"role": "assistant", "content": assistant_msg})
31
+ messages.append({"role": "user", "content": message})
32
+
33
+ inputs = tokenizer.apply_chat_template(
34
+ messages,
35
+ return_tensors="pt",
36
+ add_generation_prompt=True,
37
+ ).to(model.device)
38
+
39
+ streamer = TextIteratorStreamer(
40
+ tokenizer, skip_prompt=True, skip_special_tokens=True
41
+ )
42
+
43
+ thread = Thread(target=model.generate, kwargs={
44
+ "input_ids": inputs,
45
+ "max_new_tokens": max_tokens,
46
+ "temperature": temperature,
47
+ "top_p": 0.95,
48
+ "do_sample": temperature > 0,
49
+ "streamer": streamer,
50
+ })
51
+ thread.start()
52
+
53
+ output = ""
54
+ for token in streamer:
55
+ output += token
56
+ yield output
57
+
58
+
59
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), title="Code-IL E4B") as demo:
60
+ gr.Markdown("""
61
+ # code-il-E4B
62
+ ### 诪讜讚诇 拽讜讚 讬砖专讗诇讬 - 4 诪讬诇讬讗专讚 驻专诪讟专讬诐, 专抓 注诇 诪讞砖讘 谞讬讬讚
63
+
64
+ 诪讜讚诇 诪讘讜住住 Gemma 4 E4B 砖讗讜诪谉 注诇 OpenCodeInstruct 砖诇 NVIDIA + dataset 拽讜讚 注讘专讬-讗谞讙诇讬 诪砖诇讬.
65
+ 诪转诪讞讛 讘-Python, TypeScript, n8n, 讜转讜诪讱 讘注讘专讬转.
66
+
67
+ **By [BrainboxAI](https://huggingface.co/BrainboxAI)** - Powered by Unsloth
68
+ """)
69
+
70
+ chat = gr.ChatInterface(
71
+ fn=generate,
72
+ examples=EXAMPLES,
73
+ cache_examples=False,
74
+ additional_inputs=[
75
+ gr.Slider(0.0, 1.0, value=0.2, step=0.05, label="Temperature"),
76
+ gr.Slider(128, 2048, value=1024, step=128, label="Max Tokens"),
77
+ ],
78
+ additional_inputs_accordion=gr.Accordion("鈿欙笍 讛讙讚专讜转 诪转拽讚诪讜转", open=False),
79
+ )
80
+
81
+ gr.Markdown("""
82
+ ---
83
+ **Training**: NVIDIA OpenCodeInstruct (4.97M) + BrainboxAI/code-training-il (40k) + bleugreen/typescript-instruct (41k)
84
+ **Format**: Safetensors 16-bit | **License**: Apache 2.0 | **Languages**: English + 注讘专讬转
85
+ """)
86
+
87
+ if __name__ == "__main__":
88
+ demo.queue().launch()
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ torch
2
+ transformers>=4.45.0
3
+ accelerate
4
+ spaces
5
+ gradio>=4.44.0
6
+ sentencepiece
7
+ protobuf