--- license: apache-2.0 language: - en base_model: ibm-granite/granite-4.2-3b library_name: peft pipeline_tag: text-generation tags: - lslm - lora - gguf - llama.cpp - retrieval - rag - tool-calling - granite --- # LSLM beta — Logical Small Language Model (LoRA adapter for Granite 4.2 3B) **LSLM is a logical small language model: it reasons and talks, but looks facts up in swappable on-disk knowledge packs instead of memorizing them.** This repository holds the **LSLM beta** adapter. It turns IBM Granite 4.2 3B into the LSLM assistant used by the [LSLM app](https://github.com/andrewtab4-commits/LSLM) (code, installer and knowledge packs). LSLM's own model, trained from scratch for language and logic rather than for memorizing facts, is **in development** and will replace Granite; the app and the knowledge packs stay the same. ## Roadmap | Version | Model | State | |---|---|---| | **LSLM beta** (this repository) | IBM Granite 4.2 3B + LSLM adapter | works now | | **LSLM 1** | LSLM's own model, ~250M parameters, trained from scratch to read, reason and answer from the text it is given, not to memorize facts | in development | | **LSLM 2** | own model, ~500M parameters | next | | **LSLM 3** | own model, ~1B parameters | later: needs far more compute, so it will depend on funding and donations | | **LSLM 4** | own model, ~3B parameters, many languages | the long-term goal | ## What the adapter teaches * **Search first.** Questions that need facts go to the `search_knowledge` tool, which searches the enabled packs. * **Answer only from the passages,** even when they disagree with what the base model "remembers". * **Cite every fact** with `[n]`, pointing to the passage it came from. * **Say so when the packs have nothing,** instead of guessing. * **Answer in clear English,** whatever language the question is in. * Search again with other keywords when the first results are not enough; handle follow-up questions, small talk and simple tasks (summarising, rewriting) without searching. ## Results 150 held-out conversations (not used in training), base Granite vs Granite + LSLM adapter, same prompts and tools (llama.cpp, Q4_K_M): | Kind | n | Base | LSLM beta | |---|---|---|---| | Facts from the pack | 75 | 80% | **95%** | | Pack contradicts the model's memory | 17 | 71% | **88%** | | Needs a second search | 10 | 0% | **60%** | | Tasks (summarise, rewrite, small maths) | 14 | 36% | **93%** | | Overview of a topic | 2 | 0% | **100%** | | Question in another language → answer in English | 9 | 89% | **100%** | | Follow-up questions | 4 | 100% | 100% | | Small talk | 5 | 100% | 100% | | "Not in the packs" | 14 | 100% | 93% | | **All** | **150** | **72%** | **92%** | With the adapter, every factual answer carries a citation (base: 95%), and the model stops describing its search. Known weak spots: multi-digit arithmetic (a calculator tool is planned) and requests for general advice that the packs do not cover. ## Files | File | For | |---|---| | `lslm-lora-v1.gguf` | llama.cpp (`llama-server -m granite-4.2-3b-Q4_K_M.gguf --lora lslm-lora-v1.gguf`); downloaded by the [LSLM installer](https://github.com/andrewtab4-commits/LSLM) | | `adapter_model.safetensors`, `adapter_config.json` | PEFT / transformers, on top of `ibm-granite/granite-4.2-3b` | The base model in GGUF form: [ibm-granite/granite-4.2-3b-GGUF](https://huggingface.co/ibm-granite/granite-4.2-3b-GGUF) (`granite-4.2-3b-Q4_K_M.gguf`). ## Training * LoRA rank 16, alpha 32, dropout 0.05, on all attention and MLP projections (`q/k/v/o_proj`, `gate/up/down_proj`). * 1,800 generated conversations with real tool calls and search results from the Simple English Wikipedia pack: facts, counterfactual (edited) passages, unanswerable questions, second searches, follow-ups, overviews, tasks, small talk and non-English questions. * Loss only on the tokens the model must write; 1 epoch, 224 steps, effective batch 8, lr 1e-4 (cosine), sequences up to 3,072 tokens, bf16. * Trained on a MacBook Air M4 (16 GB) with PyTorch on Apple Silicon, about 11 hours. * Held-out eval loss: 1.07 → 0.039. ## Licence The adapter is released under Apache 2.0, like Granite 4.2 3B (© IBM). The training conversations quote Simple English Wikipedia (CC BY-SA 4.0).