Skip to content
Agentmart
Submit a tool

doc_to_lora

A method to instantly internalize document contexts into language models using LoRA without fine-tuning.

Skill by lamm-mit

IndexedApache-2.0★ 250
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/lamm-mit-doc-to-lora

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

A method to instantly internalize document contexts into language models using LoRA without fine-tuning.

Use cases: documents

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found
Runs as
Python package

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/doc-to-lora

What's inside

Skill name
doc_to_lora
Description
A method to instantly internalize document contexts into language models using LoRA without fine-tuning.
License
Apache-2.0
Instructions
144 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts
  • Instructions call the network

Agent Skills spec issues

  • name: only lowercase letters, digits and single hyphens allowed

Files (3)

  • SKILL.md
  • USAGE.md · scripts/
  • doc_to_lora_client.py · scripts/

SKILL.md (first lines)

## doc_to_lora

A method to instantly internalize document contexts into language models using LoRA without fine-tuning.

### Code repository

<https://github.com/SakanaAI/doc-to-lora>

**Use this as the implementation source:** clone the repo and follow its README for install, dependencies, and how to run code or experiments. The generated client prints JSON with a suggested ``git clone`` command.

### Paper (arXiv — explanation)

<https://arxiv.org/abs/2602.15902>

This is the **paper** reference. The client can optionally fetch live Atom metadata (title, abstract) for agents; it does **not** run training or upstream research code by itself.

### What “running” this client does

The `*_client.py` script prints **JSON** that combines a **GitHub repository** (clone URL + suggested ``git clone``) with **optional paper context** from arXiv (live Atom metadata when **reference_url** is arXiv). Run the real code by cloning the repo and following its README — the skill is your agent-facing entrypoint, not a substitute for the repo’s install steps.

To call a **REST API** instead, set ``BASE_URL`` in `scripts/doc_to_lora_client.py` or wrap the upstream CLI with ``subprocess`` after clone.

### How to run the method (from the source)

Extracted for **operators and agents**. Confirm against the upstream repository or paper before relying on it in production.

## Prerequisites
- Python 3.8+
- CUDA-capable GPU (recommended)
- Hugging Face account for model access

## Installation
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
./install.sh
```

## Configuration
### Hugging Face Authentication
Login to Hugging Face to download pre-trained models:
```bash
uv run huggingface-cli login
```

### Download Pre-Trained Models
```bash
uv run huggingface-cli download SakanaAI/doc-to-lora --local-dir trained_d2l --include "/"
```

## How to run

### Interactive Demo
```bash
uv run demo/app.py
```

### Python API Usage (Non-batched)
```python
import torch
from ctx_to_lora.model_loading import get_tokenizer
from ctx_to_lora.modeling.hypernet import ModulatedPretrainedModel

# Load model
checkpoint_path = "trained_d2l/gemma_demo/checkpoint-80000/pytorch_model.bin"
state_dict = torch.load(checkpoint_path, weights_only=False)
model = ModulatedPretrainedModel.from_state_dict(
    state_dict, train=False, use_sequence_packing=False
)
model.reset()
tokenizer = get_tokenizer(model.base_model.name_or_path)

# Prepare input
doc = open("data/sakana_wiki.txt", "r").read()
chat = [{"role": "user", "content": "Tell me about Sakana AI."}]
chat_ids = tokenizer.apply_chat_template(
    chat,
    add_special_tokens=False,
    return_attention_mask=False,
    add_generation_prompt=True,
    return_tensors="pt",
).to(model.device)

# Internalize document and generate
model.internalize(doc)
outputs = model.generate(input_ids=chat_ids, max_new_tokens=512)
print(tokenizer.decode(outputs[0]))

# Reset to remove internalized context
model.reset()
```

### Experimental Scripts
Run experiments from repository root using `uv run`:

**Main Experiment:**
```bash
uv run scripts/main_exp/0-download_data.sh
uv run scripts/main_exp/1-train.sh
uv run scripts/main_exp/eval/*.sh
```

**NIAH (Needle in a Haystack):**
```bash
uv run scripts/niah/0-gen_data.sh
uv run scripts/niah/1-train.sh
uv run scripts/niah/2-eval.sh
```

### Data Viewer
View self-generated data samples:
```bash
uv run webui/self_gen_viewer.py
```
See [webui/SELF_GEN_VIEWER.md](webui/SELF_GEN_VIEWER.md) for details.

## Configuration
- **Model checkpoint paths**: Specify via `checkpoint_path` parameter
- **Base model**: Configured in checkpoint; supports Gemma and other Hugging Face models
- **Batched inference**: For batched operations, see `src/ctx_to_lora/modeling/hypernet.py`

From lamm-mit/scienceclaw, Apache-2.0.

More from lamm-mit/scienceclaw

Signals

Stars
250
Forks
47
Open issues
1
Last commit (this folder)
Mar 25, 2026 (7 months ago)
Last release
Jun 23, 2026 (4 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from lamm-mit

Cite this page

doc_to_lora skill. Agent Mart. https://agentmart.dev/skills/lamm-mit-doc-to-lora (last updated 2026-10-24)