RecursiveCompressorLM (Pretrain)
日本語
モデル概要
RecursiveCompressor アーキテクチャによる日英バイリンガル言語モデルの事前学習版です。
独自の再帰的圧縮機構によりトークン間の長距離依存をサブリニアな計算量で扱います。
- アーキテクチャ: RecursiveCompressorLM (PreTrainedModel)
- パラメータ数: 2,601,891,840
- コンテキスト長: 2048(学習時)/推論時はより長いコンテキストも理論上対応
- トークナイザ:
elyza/ELYZA-japanese-Llama-2-7b-fast
- dtype: bfloat16
モデル構造
| パラメータ | 値 |
|---|
| d_model | 2048 |
| num_heads | 16 |
| d_ff | 6144 |
| chunk_size | 4 |
| compress_size | 1 |
| num_layers | 16 |
訓練データ
事前学習に以下の文書データセットを使用しました(対話データは含みません):
| データセット | 言語 | ライセンス |
|---|
wikimedia/wikipedia (20231101.ja) | 日本語 | CC BY-SA 4.0 / GFDL |
wikimedia/wikipedia (20231101.en) | 英語 | CC BY-SA 4.0 / GFDL |
hotchpotch/cc100-ja-documents | 日本語 | Common Crawl Terms of Use |
JeanKaddour/minipile | 英語 | MIT (The Pileの派生) |
訓練設定
- オプティマイザ: Muon (隠れ層2D重み) + AdamW (embedding/head/bias/norm)
- 学習率: 5e-5
- 並列方式: パイプライン並列 (PyTorch PipelineStage + Schedule1F1B, 6 GPUs)
- バッチ: マイクロバッチ6 × バッチサイズ6
- 混合精度: fp32マスター重み + bfloat16 autocast
- ハードウェア: NVIDIA RTX 3090 × 6
用途
- 想定用途: 日本語/英語の文章生成、続きの生成、追加ファインチューニングのベース
- 非想定用途: 質問応答・対話(→ instruct版を参照)、医療/法律/金融などの高リスク判断
使い方
本モデルは独自アーキテクチャ RecursiveCompressorLM を使用するため、
以下のリポジトリをクローンしてその中のクラス定義を読み込む必要があります:
1git clone https://github.com/myxyy/RecursiveCompressorHF.git -b v1.2
2cd RecursiveCompressorHF
3uv sync
HuggingFaceの generate() メソッドに対応しています:
1import torch
2from transformers import AutoTokenizer, TextStreamer
3from recursive_compressor_lm import RecursiveCompressorLM
4model = RecursiveCompressorLM.from_pretrained(
5 "myxy/recursive-compressor-v1.2-2.6b-c4c1",
6 torch_dtype=torch.bfloat16,
7).to("cuda").eval()
8tokenizer = AutoTokenizer.from_pretrained("elyza/ELYZA-japanese-Llama-2-7b-fast")
9prompt = "吾輩は猫である。"
10input_ids = tokenizer.encode(prompt, return_tensors="pt").to("cuda")
11output_ids = model.generate(
12 input_ids,
13 max_new_tokens=256,
14 do_sample=True,
15 temperature=0.8,
16 top_p=0.9,
17 streamer=TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True),
18)
19#print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
リポジトリ内の predict.py / predict_stream.py も同等の機能を提供します(インタラクティブREPL等)。
注: beam searchは未対応です(do_sample=Falseの貪欲生成、またはdo_sample=Trueの確率サンプリングを使用してください)。
制限・バイアス
- 訓練データのバイアス(Wikipediaやウェブ文書の偏り)を反映する可能性
- 事実関係の誤り(hallucination)が起こりうる
- 数値計算・論理推論は不得手
- 安全性フィルタは未実装
ライセンス
Llama 2 Community License に従います。
- ライセンス全文: https://llama.meta.com/llama2/license/
- 「Built with Meta Llama 2」と明示する必要があります
- MAU 7億超の事業者は別途ライセンス取得が必要
トークナイザが Llama 2 派生であるため、本モデルもこのライセンスに従います。
引用
TODO
English
Model Description
A bilingual (Japanese / English) pretrained causal language model using the
RecursiveCompressor architecture, which handles long-range token dependencies
in sublinear computational complexity via recursive compression.
- Architecture: RecursiveCompressorLM (extends
PreTrainedModel)
- Parameters: 2,601,891,840
- Training context length: 2048 (longer contexts theoretically supported at inference)
- Tokenizer:
elyza/ELYZA-japanese-Llama-2-7b-fast
- dtype: bfloat16
Architecture
| Parameter | Value |
|---|
| d_model | 2048 |
| num_heads | 16 |
| d_ff | 6144 |
| chunk_size | 4 |
| compress_size | 1 |
| num_layers | 16 |
Training Data
Pretrained on document datasets only (no dialogue data):
| Dataset | Language | License |
|---|
wikimedia/wikipedia (20231101.ja) | Japanese | CC BY-SA 4.0 / GFDL |
wikimedia/wikipedia (20231101.en) | English | CC BY-SA 4.0 / GFDL |
hotchpotch/cc100-ja-documents | Japanese | Common Crawl Terms of Use |
JeanKaddour/minipile | English | MIT (subset of The Pile) |
Training Setup
- Optimizers: Muon (2D hidden weights) + AdamW (embedding/head/bias/norm)
- Learning rate: 5e-5
- Parallelism: pipeline parallel (PyTorch PipelineStage + Schedule1F1B, 6 GPUs)
- Batch: 6 microbatches × batch size 6
- Mixed precision: fp32 master weights + bfloat16 autocast
- Hardware: NVIDIA RTX 3090 × 6
Usage
This model uses the custom RecursiveCompressorLM architecture, so you need
to clone the repository to import the class definitions:
1git clone https://github.com/myxyy/RecursiveCompressorHF.git -b v1.2
2cd RecursiveCompressorHF
3uv sync
The model supports HuggingFace's generate() method:
1import torch
2from transformers import AutoTokenizer, TextStreamer
3from recursive_compressor_lm import RecursiveCompressorLM
4model = RecursiveCompressorLM.from_pretrained(
5 "myxy/recursive-compressor-v1.2-2.6b-c4c1",
6 torch_dtype=torch.bfloat16,
7).to("cuda").eval()
8tokenizer = AutoTokenizer.from_pretrained("elyza/ELYZA-japanese-Llama-2-7b-fast")
9prompt = "Once upon a time"
10input_ids = tokenizer.encode(prompt, return_tensors="pt").to("cuda")
11output_ids = model.generate(
12 input_ids,
13 max_new_tokens=256,
14 do_sample=True,
15 temperature=0.8,
16 top_p=0.9,
17 streamer=TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True),
18)
19print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
See predict.py / predict_stream.py in the repository for an interactive REPL.
Note: beam search is not supported (use do_sample=False for greedy or do_sample=True for sampling).
Intended Use
- Intended: Text completion in Japanese / English; base for downstream fine-tuning
- Not intended: Question answering / dialogue (see the instruct variant); high-stakes decisions in medical, legal, or financial domains
Limitations & Bias
- May reflect biases present in Wikipedia and web text
- May produce factually incorrect statements (hallucination)
- Limited capability in arithmetic and logical reasoning
- No safety filtering
License
Llama 2 Community License.
- Full text: https://llama.meta.com/llama2/license/
- "Built with Meta Llama 2" attribution required
- Organizations with > 700M MAU must seek a separate license
The tokenizer is derived from Llama 2, hence this model inherits the license.
Citation
TODO
Acknowledgments
- Meta AI for Llama 2
- ELYZA for the Japanese-extended tokenizer
- Wikimedia Foundation, hotchpotch, JeanKaddour for training data