Downloads · 30 days
32
0% of all-time downloads
pathcosmos/EVAFRILL-Mo-3B
EVAFRILL-Mo-3B is a text generation model from pathcosmos. Use it when you need the model to write or continue text. It is set up for pytorch. The card lists the license as mit.
Downloads · 30 days
32
0% of all-time downloads
All-time downloads
7.2K
Public
Parameters
3.2B
53.3 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors56.7 GB · 95%
From the Hugging Face model README
EVAFRILL-Mo 3B는 NVIDIA Nemotron-H 아키텍처에서 영감을 받아 밑바닥부터 직접 구현한 30억 파라미터 하이브리드 언어 모델입니다.
Type: Hybrid Mamba-2 + Transformer
Parameters: 2.94B (2,975,397,632)
Layers: 26 (24× Mamba-2 SSM + 2× Attention GQA)
d_model: 3,072
Vocabulary: 64,000 (custom SentencePiece)
Max seq length: 4,096
Mamba-2 SSM 블록이 장거리 의존성을 효율적으로 처리하고, 2개의 GQA Attention 블록이 전역 컨텍스트를 보완합니다. 표준 Transformer 대비 추론 시 KV 캐시 메모리를 크게 절감합니다.
EVAFRILL-Mo는 6단계의 반복적 설계 과정을 거쳐 탄생했습니다:
| 기술 | 효과 |
|---|---|
| Chunked Cross-Entropy | 64K 어휘에서 logits 메모리 사용량을 1/8로 절감 |
| Mamba Memory Cliff 발견 | batch 6→7에서 47GB→183GB+ 폭증 — selective scan의 구조적 제약 규명 |
| FP8 네이티브 학습 | TransformerEngine MXFP8BlockScaling으로 B200에서 BF16 대비 ~2배 처리량 |
| LoRA B-zeroing | DPO reference model을 모델 복제 없이 LoRA B를 임시 0으로 만들어 계산 — VRAM 50% 절약 |
| SLERP 체크포인트 병합 | SFT 지식 보존 + DPO 정렬을 구면 보간으로 균형 — alignment tax 완화 |
| Native DPO/ORPO | TRL 미사용, 커스텀 Mamba-2 하이브리드를 위해 처음부터 PyTorch로 구현 |
📖 전체 개발 과정, 아키텍처 설계 근거, 하드웨어 최적화 상세는 GitHub README를 참조하세요.
이 저장소에는 학습 파이프라인 각 단계의 체크포인트 7종이 포함됩니다.
| 버전 | 디렉토리 | 크기 | 설명 | 권장 |
|---|---|---|---|---|
| SLERP | slerp/ | 6.3 GB | SFT + DPO R2 구면 선형 보간 (α=0.5) | ⭐ |
| Pretrain | pretrain/ | 12.6 GB | 기반 모델 (319K 스텝, 55B 토큰) | |
| SFT v2 | sft-v2/ | 6.3 GB | 명령어 파인튜닝 (65K 스텝) | |
| DPO R1 | dpo-r1/ | 6.3 GB | 선호도 정렬 1라운드 (3K 스텝) | |
| DPO R2 | dpo-r2/ | 6.3 GB | 보수적 파인튜닝 2라운드 (2K 스텝) | |
| ORPO | orpo/ | 6.3 GB | SFT+정렬 동시 학습 실험 (10K 스텝) | |
| DPO R3 | dpo-r3/ | 6.3 GB | 반복 억제 특화 실험 (1K 스텝) |
Pretrain (55B tokens, 7×B200, 60h)
└─► SFT v2 (65K steps, H100 MIG, 5일)
├─► DPO R1 (3K steps) ─► DPO R2 (2K steps)
│ └─► SLERP Merge (α=0.5) ⭐ 최종 권장
└─► ORPO (10K steps, 실험)
└─► DPO R3 (1K steps, 반복 특화 실험)
각 화살표는 독립된 체크포인트로 저장되어, 임의의 단계부터 재현·비교가 가능합니다.
평가 대상: SLERP 모델 (0-shot, limit=500)
| 벤치마크 | 정확도 |
|---|---|
| HellaSwag | 34.6% |
| ARC-Easy | 32.0% |
| Belebele 한국어 | 23.6% |
| Global MMLU 한국어 | 23.7% |
반복 생성 억제 (greedy decoding 기준)
| 설정 | 3-gram 반복률 |
|---|---|
| rep_penalty 없음 | 74.5% |
| rep_penalty=1.2 | 5.5% |
권장 추론 파라미터: temperature=0.7, repetition_penalty=1.2
| 지표 | SLERP (SFT→DPO) | ORPO | 우세 |
|---|---|---|---|
| Greedy 반복률 | 74.5% | 87.1% | SLERP |
| 대화 품질 | 자연스러움 | 부자연스러움 | SLERP |
| HellaSwag | 39.0% | 35.0% | SLERP |
| 학습 시간 | 5일+8시간 | 12.8시간 | ORPO |
ORPO의 약점: SFT 65K 스텝 대비 10K 스텝만 학습되어 기반 명령어 이해가 부족합니다.
GGUF/Ollama 미지원: 커스텀 Mamba-2 하이브리드 아키텍처로 llama.cpp/GGUF/Ollama와 호환되지 않습니다. PyTorch 직접 추론만 가능합니다.
사전 준비:
# 1. 소스 코드 클론 (커스텀 아키텍처 모듈 필요)
git clone https://github.com/pathcosmos/EVAFRILL-Mo
cd EVAFRILL-Mo
# 2. 의존성 설치
pip install torch safetensors tokenizers PyYAML
방법 1: safetensors 직접 로딩 (권장)
import json
import torch
from model.config import LMConfig
from model.transformer import LLM
from tokenizers import Tokenizer
from safetensors.torch import load_file as load_safetensors
CKPT = "path/to/EVAFRILL-Mo-3B/slerp" # 이 저장소의 slerp/ 디렉토리
# Config & 모델 로드
with open(f"{CKPT}/config.json") as f:
data = json.load(f)
for k in ("model_type", "architectures", "_variant", "_description"):
data.pop(k, None)
cfg = LMConfig(**data)
cfg.use_flash_attn = False
model = LLM(cfg)
state = load_safetensors(f"{CKPT}/model.safetensors", device="cpu")
model.load_state_dict(state, strict=False)
model = model.to(device="cuda:0", dtype=torch.bfloat16)
model.eval()
tok = Tokenizer.from_file(f"{CKPT}/tokenizer.json")
# 생성 (권장: temp=0.7, rep_penalty=1.2)
prompt = "<|user|>\n인공지능이란 무엇인가요?\n<|assistant|>\n"
ids = torch.tensor([tok.encode(prompt).ids], device="cuda:0")
with torch.no_grad():
for _ in range(256):
logits, _ = model(ids)
logits = logits[:, -1, :].float()
for prev_id in set(ids[0].tolist()):
if logits[0, prev_id] > 0: logits[0, prev_id] /= 1.2
else: logits[0, prev_id] *= 1.2
probs = torch.softmax(logits / 0.7, dim=-1)
next_id = torch.multinomial(probs, 1)
ids = torch.cat([ids, next_id], dim=1)
if next_id.item() == tok.token_to_id("</s>"): break
print(tok.decode(ids[0].tolist()))
방법 2: 평가 프레임워크 러너 사용
frankenstallm_test의 evafrill_runner.py가 위 과정을 래핑합니다:
from eval_framework.evafrill_runner import generate, unload_model
result = generate("한국어로 인사해주세요.")
print(result["response"])
print(f"속도: {result['tokens_per_sec']:.1f} TPS")
unload_model()
설정 방법: frankenstallm_test README 참조
시스템 요구사항: GPU VRAM 8GB+ (BF16), CPU 추론 가능하지만 극히 느림 (~0.5 TPS)
| 경로 | 내용 |
|---|---|
data/combined_preference.jsonl | 선호도 학습 데이터 (684K 쌍, 2.6 GB) |
data/repetition_preference.jsonl | 반복 억제 선호도 데이터 (105 쌍, 자동 생성) |
configs/korean_3b_sft_1gpu.yaml | SFT H100 MIG 설정 |
configs/dpo_3b_1gpu.yaml | DPO 학습 설정 |
configs/orpo_3b_1gpu.yaml | ORPO 학습 설정 |
scripts/dpo.py | DPO 학습 코드 |
scripts/orpo_native.py | ORPO 학습 코드 |
scripts/sft.py | SFT 학습 코드 |
scripts/evafrill_eval.py | 벤치마크 평가 코드 |
scripts/merge_checkpoints.py | SLERP 체크포인트 병합 |
repetition_penalty=1.2 이상을 설정하세요.MIT License — 상업적 이용·수정·재배포 모두 자유롭습니다.
EVAFRILL-Mo 3B is a 3-billion-parameter hybrid language model built entirely from scratch, inspired by NVIDIA's Nemotron-H architecture.
Type: Hybrid Mamba-2 + Transformer
Parameters: 2.94B (2,975,397,632)
Layers: 26 (24× Mamba-2 SSM + 2× Attention GQA)
d_model: 3,072
Vocabulary: 64,000 (custom SentencePiece)
Max seq length: 4,096
Mamba-2 SSM blocks handle long-range dependencies efficiently while two GQA Attention blocks provide global context. Compared to standard Transformers, this architecture significantly reduces KV cache memory during inference.
EVAFRILL-Mo was built through 6 iterative design stages:
| Technique | Impact |
|---|---|
| Chunked Cross-Entropy | Reduces logits memory by 8× for 64K vocabulary |
| Mamba Memory Cliff Discovery | Batch 6→7 causes 47GB→183GB+ explosion — structural limitation of selective scan |
| FP8 Native Training | TransformerEngine MXFP8BlockScaling delivers ~2× throughput vs BF16 on B200 |
| LoRA B-zeroing | Computes DPO reference logprobs without model duplication — 50% VRAM savings |
| SLERP Checkpoint Merging | Balances SFT knowledge + DPO alignment via spherical interpolation — mitigates alignment tax |
| Native DPO/ORPO | No TRL dependency — implemented from scratch in PyTorch for custom Mamba-2 hybrid |
📖 For the complete development journey, architecture design rationale, and hardware optimization details, see the GitHub README.
This repository contains 7 checkpoints representing each stage of the training pipeline.
| Variant | Directory | Size | Description | Recommended |
|---|---|---|---|---|
| SLERP | slerp/ | 6.3 GB | Spherical interpolation of SFT + DPO R2 (α=0.5) | ⭐ |
| Pretrain | pretrain/ | 12.6 GB | Base model (319K steps, 55B tokens) | |
| SFT v2 | sft-v2/ | 6.3 GB | Instruction-tuned (65K steps) | |
| DPO R1 | dpo-r1/ | 6.3 GB | Preference-aligned Round 1 (3K steps) | |
| DPO R2 | dpo-r2/ | 6.3 GB | Conservative fine-tuning Round 2 (2K steps) | |
| ORPO | orpo/ | 6.3 GB | Simultaneous SFT+alignment experiment (10K steps) | |
| DPO R3 | dpo-r3/ | 6.3 GB | Repetition-targeted experiment (1K steps) |
Pretrain (55B tokens, 7×B200, 60h)
└─► SFT v2 (65K steps, H100 MIG, 5 days)
├─► DPO R1 (3K steps) ─► DPO R2 (2K steps)
│ └─► SLERP Merge (α=0.5) ⭐ Final Recommended
└─► ORPO (10K steps, experimental)
└─► DPO R3 (1K steps, repetition experiment)
Every arrow corresponds to a separate saved checkpoint, enabling reproduction and comparison from any stage.
Evaluated on: SLERP model (0-shot, limit=500)
| Benchmark | Accuracy |
|---|---|
| HellaSwag | 34.6% |
| ARC-Easy | 32.0% |
| Belebele Korean | 23.6% |
| Global MMLU Korean | 23.7% |
Repetition suppression (greedy decoding)
| Setting | 3-gram repetition rate |
|---|---|
| No rep_penalty | 74.5% |
| rep_penalty=1.2 | 5.5% |
Recommended inference parameters: temperature=0.7, repetition_penalty=1.2
| Metric | SLERP (SFT→DPO) | ORPO | Winner |
|---|---|---|---|
| Greedy repetition | 74.5% | 87.1% | SLERP |
| Chat quality | Fluent | Broken | SLERP |
| HellaSwag | 39.0% | 35.0% | SLERP |
| Training time | 5d+8h | 12.8h | ORPO |
ORPO's weakness: only 10K steps of training vs SFT's 65K — insufficient base instruction-following before alignment kicks in.
GGUF/Ollama not supported: Custom Mamba-2 hybrid architecture is incompatible with llama.cpp/GGUF/Ollama. PyTorch direct inference only.
Prerequisites:
# 1. Clone source code (custom architecture modules required)
git clone https://github.com/pathcosmos/EVAFRILL-Mo
cd EVAFRILL-Mo
# 2. Install dependencies
pip install torch safetensors tokenizers PyYAML
Method 1: Direct safetensors loading (recommended)
import json
import torch
from model.config import LMConfig
from model.transformer import LLM
from tokenizers import Tokenizer
from safetensors.torch import load_file as load_safetensors
CKPT = "path/to/EVAFRILL-Mo-3B/slerp" # slerp/ directory of this repo
# Load config & model
with open(f"{CKPT}/config.json") as f:
data = json.load(f)
for k in ("model_type", "architectures", "_variant", "_description"):
data.pop(k, None)
cfg = LMConfig(**data)
cfg.use_flash_attn = False
model = LLM(cfg)
state = load_safetensors(f"{CKPT}/model.safetensors", device="cpu")
model.load_state_dict(state, strict=False)
model = model.to(device="cuda:0", dtype=torch.bfloat16)
model.eval()
tok = Tokenizer.from_file(f"{CKPT}/tokenizer.json")
# Generate (recommended: temp=0.7, rep_penalty=1.2)
prompt = "<|user|>\nWhat is artificial intelligence?\n<|assistant|>\n"
ids = torch.tensor([tok.encode(prompt).ids], device="cuda:0")
with torch.no_grad():
for _ in range(256):
logits, _ = model(ids)
logits = logits[:, -1, :].float()
for prev_id in set(ids[0].tolist()):
if logits[0, prev_id] > 0: logits[0, prev_id] /= 1.2
else: logits[0, prev_id] *= 1.2
probs = torch.softmax(logits / 0.7, dim=-1)
next_id = torch.multinomial(probs, 1)
ids = torch.cat([ids, next_id], dim=1)
if next_id.item() == tok.token_to_id("</s>"): break
print(tok.decode(ids[0].tolist()))
Method 2: Evaluation framework runner
The evafrill_runner.py in frankenstallm_test wraps the above into a simple API:
from eval_framework.evafrill_runner import generate, unload_model
result = generate("Hello, please introduce yourself.")
print(result["response"])
print(f"Speed: {result['tokens_per_sec']:.1f} TPS")
unload_model()
Setup instructions: frankenstallm_test README
System requirements: GPU VRAM 8GB+ (BF16), CPU inference possible but extremely slow (~0.5 TPS)
| Path | Contents |
|---|---|
data/combined_preference.jsonl | Preference training data (684K pairs, 2.6 GB) |
data/repetition_preference.jsonl | Repetition-suppression preference data (105 pairs, auto-generated) |
configs/korean_3b_sft_1gpu.yaml | SFT config for H100 MIG |
configs/dpo_3b_1gpu.yaml | DPO training config |
configs/orpo_3b_1gpu.yaml | ORPO training config |
scripts/dpo.py | DPO training code |
scripts/orpo_native.py | ORPO training code |
scripts/sft.py | SFT training code |
scripts/evafrill_eval.py | Benchmark evaluation code |
scripts/merge_checkpoints.py | SLERP checkpoint merging |
repetition_penalty — always use repetition_penalty >= 1.2.이 프로젝트는 과학기술정보통신부의 「첨단 GPU 활용 지원 사업」 (과학기술정보통신부 공고 제2025-1068호)을 통해 제공된 GPU 컴퓨팅 자원을 활용하여 수행되었습니다.
국가 AI컴퓨팅자원 지원포털: https://aiinfrahub.kr
- 주관: 과학기술정보통신부 (MSIT), 정보통신산업진흥원 (NIPA)
- 운영: 한국정보통신진흥협회 (KAIT)
대한민국 정부의 AI 인프라 지원 사업 덕분에 7× NVIDIA B200 GPU 환경에서 한국어 3B 하이브리드 Mamba-Transformer 모델을 처음부터 학습할 수 있었습니다. 국가 차원의 AI 컴퓨팅 자원 지원에 깊이 감사드립니다.
This project was conducted using GPU computing resources provided through the "Advanced GPU Utilization Support Program" (MSIT Notice No. 2025-1068) by the Ministry of Science and ICT (MSIT) of the Republic of Korea.
National AI Computing Resource Support Portal: https://aiinfrahub.kr
- Organized by: Ministry of Science and ICT (MSIT), National IT Industry Promotion Agency (NIPA)
- Operated by: Korea Association of Information & Telecommunication (KAIT)
We are deeply grateful for the national-level AI computing infrastructure support from the Korean government, which made it possible to train a Korean 3B hybrid Mamba-Transformer model from scratch on 7× NVIDIA B200 GPUs.
MIT License — free to use, modify, and distribute commercially.