File size: 2,856 Bytes
2f4ad24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
base_model: Qwen/Qwen2.5-0.5B-Instruct
library_name: peft
pipeline_tag: text-generation
license: apache-2.0
tags: [lora, peft, legal, law, legal-research, cpu, c0mpute, ollama]
---

# not-a-lawyer-agent

> **Not a lawyer. Not legal advice. Legal research from public sources; laws vary by jurisdiction, so check with a licensed attorney before acting.**

**Quick start (Ollama, runs on a CPU):**

```bash
ollama run hf.co/profullstack/not-a-lawyer-agent-GGUF "Can my landlord keep my whole security deposit for normal wear and tear?"
```

Needs Ollama 0.3.13 or newer (`curl -fsSL https://ollama.com/install.sh | sh`, or `w3bs install ollama`).
The GGUF is at [profullstack/not-a-lawyer-agent-GGUF](https://huggingface.co/profullstack/not-a-lawyer-agent-GGUF); this repo is the LoRA adapter.

| | |
| --- | --- |
| base | Qwen/Qwen2.5-0.5B-Instruct |
| corpus | 5963 documents from pit-index:law,legal,lawyer,lawsuit,court ruling,contract law,copyright,tenant rights,employment law,small claims, topic:law, topic:legal, topic:lawyer, topic:lawsuit, topic:court, topic:copyright, topic:contract-law, topic:legal-tech |
| training | 400 LoRA steps (r=8, seq_len=256, lr=0.0002) on the c0mpute network (`infernet.text.train`, job `3088dff7-b5a6-4969-a40e-5d250d6fa920`, receipt hash `sha256:88140d7fe1c84b0bd03cc4b70838caef984c80d702d470e88595b08a22552ed6` matches this adapter) |
| held-out perplexity | 35.4 to 20.6 |
| adapter sha256 | `88140d7fe1c84b0bd03cc4b70838caef984c80d702d470e88595b08a22552ed6` |

Built with the [c0mpute example](https://github.com/profullstack/c0mpute/tree/master/examples/business-strategist-agent).
Sources are rssamplifier.com topic feeds and pit.world search; the corpus is not redistributed here.

## Use from Python (adapter)

```python
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

tok = AutoTokenizer.from_pretrained("profullstack/not-a-lawyer-agent")
model = PeftModel.from_pretrained(AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct"), "profullstack/not-a-lawyer-agent")
msgs = [{"role": "system", "content": "You are not-a-lawyer-agent, a legal research assistant. You are not a lawyer and this is not legal advice. Explain the law in plain English, name the jurisdiction a rule comes from, cite the sources you were given, and say when someone should talk to a licensed attorney."},
        {"role": "user", "content": "Can my landlord keep my whole security deposit for normal wear and tear?"}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt")
print(tok.decode(model.generate(ids, max_new_tokens=300)[0][ids.shape[1]:], skip_special_tokens=True))
```

Best results come from putting fresh search results in the prompt (the example's `chat.py`
uses pit.world search): a sub-1B model supplies the voice, not the facts.