Downloads · 30 days
19
10% of all-time downloads
Pomilon/LEMA-llama-2-7b
LEMA-llama-2-7b is a text generation model from Pomilon. Use it when you need the model to write or continue text. The card lists the license as mit.
This model is a demonstration of the LEMA (Layer-wise Efficient Memory Abstraction) framework. It proves that large language models (7B+) can be fine-tuned on consumer-grade hardware with limited VRAM (e.g., 16GB Tesl…
Downloads · 30 days
19
10% of all-time downloads
All-time downloads
197
Public
Parameters
6.7B
36.6 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors13.5 GB · 97%
From the Hugging Face model README
This model is a demonstration of the LEMA (Layer-wise Efficient Memory Abstraction) framework. It proves that large language models (7B+) can be fine-tuned on consumer-grade hardware with limited VRAM (e.g., 16GB Tesla P100) by virtualizing GPU memory.
Key Achievement: Fine-tuned Llama-2-7B using only 6.36 GB of VRAM (standard LoRA typically requires ~14GB+ for this configuration).
Training code is available over on the github repository: LEMA-llama
NousResearch/Llama-2-7b-hfThe model was trained to learn a strict custom chat format ([LEMA_REPLY]) to verify that weight updates were successfully applied.
| Metric | Standard PEFT/LoRA | LEMA (This Run) |
|---|---|---|
| Peak VRAM | OOM | 6.36 GB |
| System RAM | OOM | 2.40 GB |
Note: Standard PEFT typically OOMs at Batch Size 4-8 on 16GB cards with 512 context. LEMA held steady at <7GB.
The training loss converged smoothly, demonstrating stable learning despite the layer-wise streaming architecture.
Step 10/625 | Loss: 2.1732 | VRAM: 6.36GB
Step 100/625 | Loss: 0.0677 | VRAM: 6.36GB
Step 200/625 | Loss: 0.0462 | VRAM: 6.36GB
Step 300/625 | Loss: 0.0407 | VRAM: 6.36GB
Step 400/625 | Loss: 0.0412 | VRAM: 6.36GB
Step 500/625 | Loss: 0.0459 | VRAM: 6.36GB
Step 600/625 | Loss: 0.0406 | VRAM: 6.36GB
Final Step | Training Complete
Full raw logs over Here
⚠️ Warning: Experimental Proof-of-Concept
This model was trained for only 1 epoch as a mechanical stress test of the LEMA library. While it successfully learned the new vocabulary and special tags, it has not yet mastered the logical structure or grammar of the custom template.
[LEMA_REPLY] multiple times in a loop.Explanation: and Confidence: fields.To achieve production-grade results and make the model actually usable for general tasks, it is recommended to train for 3-5 epochs with a much larger, more diverse dataset (50k+ examples).
This model uses a custom prompt format for testing purposes:
<|system|>
You are a precise assistant trained using LEMA.
<|user|>
What is LEMA?
<|assistant|>
[LEMA_REPLY]
Answer: ...
Explanation: ...
Confidence: High
[/LEMA_REPLY]
Since this model has been merged (LoRA adapter integrated into base), you can load it as a standard Llama model:
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("Pomilon/LEMA-llama-2-7b")
tokenizer = AutoTokenizer.from_pretrained("Pomilon/LEMA-llama-2-7b")
prompt = "<|system|>\nYou are a precise assistant trained using LEMA.\n\n<|user|>\nWhat is LEMA?\n\n<|assistant|>\n[LEMA_REPLY]\nAnswer:"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
output = model.generate(**inputs, max_new_tokens=100)
print(tokenizer.decode(output[0]))
LEMA is an experimental framework designed to democratize LLM fine-tuning. It treats model weights as a stream of data rather than a static block, allowing models to be processed layer-by-layer. This trades computation time (latency) for massive memory savings.