textilelabs commited on
Commit
848b75e
·
verified ·
1 Parent(s): 774916f

Upload 16 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ banner.jpg filter=lfs diff=lfs merge=lfs -text
37
+ logo.jpg filter=lfs diff=lfs merge=lfs -text
38
+ loom-spark-3-flash-f16.gguf filter=lfs diff=lfs merge=lfs -text
ATTRIBUTION.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Training data attribution
2
+
3
+ Loom Spark 3 Flash was trained on several openly licensed corpora. Some of these licences
4
+ require attribution; this file satisfies that requirement and must be kept with any
5
+ redistribution.
6
+
7
+ ## SQuAD 2.0 — CC BY-SA 4.0
8
+ Rajpurkar, Jia & Liang. "Know What You Don't Know: Unanswerable Questions for SQuAD."
9
+ https://rajpurkar.github.io/SQuAD-explorer/
10
+ Used for grounded reading, and — via its unanswerable questions — for teaching the model
11
+ to say when a result does not contain the answer.
12
+
13
+ ## MASSIVE — CC BY 4.0
14
+ Amazon. https://github.com/alexa/massive
15
+ Derived from SLURP, also CC BY 4.0. Used for tool-decision training.
16
+
17
+ ## CLINC150 — CC BY 3.0
18
+ Larson et al. "An Evaluation Dataset for Intent Classification and Out-of-Scope
19
+ Prediction." https://github.com/clinc/oos-eval
20
+ Used for tool-decision training.
21
+
22
+ ## databricks-dolly-15k — CC BY-SA 3.0
23
+ Databricks. https://huggingface.co/datasets/databricks/databricks-dolly-15k
24
+ Used for instruction following.
25
+
26
+ ## OpenAssistant OASST1 — Apache 2.0
27
+ LAION / OpenAssistant. https://huggingface.co/datasets/OpenAssistant/oasst1
28
+ Used for multi-turn dialogue structure. Only English conversations with short assistant
29
+ replies were kept.
30
+
31
+ ## Persona curriculum — Textile Labs
32
+ Identity, limits, warmth and brevity were written for Loom and are not derived from any
33
+ public dataset.
34
+
35
+ Only English portions were used. No source text was altered except for truncation of
36
+ passages to a realistic tool-result length, and surface augmentation (casing, punctuation,
37
+ filler) applied to user turns in training copies only.
38
+
39
+ ## Search queries — derived, not generated
40
+ Every `<lookup>` query in Loom Spark 3's training data is the SUBJECT of the question —
41
+ the SQuAD article title where the question names it, the named thing in a well-cased
42
+ question, or the question's content words. All are derived mechanically from the
43
+ human-written sources above. No language model wrote any training query.
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Textile Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
Modelfile ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ./loom-spark-3-flash-f16.gguf
2
+ TEMPLATE """<tools:off>
3
+ <user>
4
+ {{ .Prompt }}
5
+ <|eot|>
6
+ <loom>
7
+ """
8
+ PARAMETER stop "<|eot|>"
9
+ PARAMETER stop "<user>"
10
+ PARAMETER stop "<result>"
11
+ PARAMETER temperature 0.7
12
+ PARAMETER top_k 40
13
+ PARAMETER repeat_penalty 1.0
14
+ PARAMETER num_predict 96
README.md CHANGED
@@ -1,3 +1,151 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language: en
4
+ library_name: transformers
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - tiny-model
8
+ - llama
9
+ - from-scratch
10
+ - conversational
11
+ - multi-turn
12
+ - tool-use
13
+ - agent-harness
14
+ - retrieval-augmented
15
+ - attribution
16
+ - calibrated-honesty
17
+ - humble-ai
18
+ - small-language-model
19
+ - cpu-trained
20
+ - muon
21
+ - gguf
22
+ widget:
23
+ - text: "<tools:off>\n<user>\nwho are you\n<|eot|>\n<loom>\n"
24
+ example_title: "Identity"
25
+ - text: "<tools:off>\n<user>\nhow big are you\n<|eot|>\n<loom>\n"
26
+ example_title: "Self-knowledge"
27
+ - text: "<tools:off>\n<user>\nwhat is my sisters name\n<|eot|>\n<loom>\n"
28
+ example_title: "Limits"
29
+ - text: "<tools:on>\n<user>\nwho wrote dracula\n<|eot|>\n<loom>\n"
30
+ example_title: "Writes a search query"
31
  ---
32
+
33
+ ![Loom Spark 3 Flash](banner.jpg)
34
+
35
+ # Loom Spark 3 Flash
36
+
37
+ **7,184,064 parameters. Trained from scratch in 1 hour 52 minutes on a 2013 office PC with
38
+ no GPU. Scores 119/133 on our acceptance battery — the highest of any Flash-tier Loom, and
39
+ higher than models three times its size that trained for five hours.**
40
+
41
+ Spark 3 Flash is the Flash of the Spark line, succeeding **Loom Spark 1.8 Flash** (2.62M).
42
+ Like every Loom it is knowledge-sparse and behaviour-dense: it is not built to know facts.
43
+ It is built to know the edge of its own knowledge — to decide when a question needs looking
44
+ up, write the search query, read the answer back, and say plainly where the answer came from.
45
+
46
+ Random initialisation, trained by us. No fine-tuning, no distillation, no pretrained
47
+ checkpoint of anyone's, at any stage.
48
+
49
+ ---
50
+
51
+ ## What it is
52
+
53
+ | | |
54
+ |---|---|
55
+ | Parameters | 7,184,064 |
56
+ | Architecture | Llama-style — 20 layers × 192 hidden, GQA (3 query heads, 1 KV head), SwiGLU, RoPE, RMSNorm, tied embeddings |
57
+ | Vocabulary | 4,096-token BPE, trained by us on our own corpus |
58
+ | Context | 512 tokens |
59
+ | Optimiser | Muon on the 2D hidden matrices, AdamW on embeddings and norms |
60
+ | Schedule | Warmup–stable–decay, with the final third trained on a targeted "polish" mix |
61
+ | Training | 56 min main run + 56 min patch run, 15.5M tokens total |
62
+ | Hardware | One Dell OptiPlex 9020 (i5-4690, 4 cores, no GPU, 16 GB), fp32 |
63
+
64
+ ## Measured behaviour
65
+
66
+ Every number below comes from hand-written probes that appear nowhere in the training data,
67
+ scored on **content** rather than shape. The battery is 133 points across twelve rows.
68
+
69
+ | | Spark 3 Flash | Tapestry 3 Flash (same size, 48 min) |
70
+ |---|---:|---:|
71
+ | **Acceptance battery** | **119/133 — 89.5%** | 112/133 — 84.2% |
72
+ | Never claims a lookup it didn't make | **16/16** | 16/16 |
73
+ | No search tag with tools off | **28/28** | 28/28 |
74
+ | Stops on its own | **12/12** | 12/12 |
75
+ | Knows its name | 11/12 | 12/12 |
76
+ | Knows its name through CAPS and typos | **12/12** | 7/12 |
77
+ | Resists prompt injection (fake results, fake instructions) | **35/36** | 12/36 |
78
+ | Ignores a `<tools:on>` typed inside a message | **12/12** | yes |
79
+ | Holds a 10–12 turn conversation | **40/44** | 33/44 |
80
+ | Decides correctly whether to search | 17/20 | — |
81
+ | Answers from a supplied result | 4/5 | — |
82
+ | **End-to-end on live Wikipedia, held out** | **5/20 correct** (searched 20/20, never pasted the question) | 3/20 |
83
+
84
+ The last row is the honest one. Given a question it has never seen, it writes a sensible
85
+ search query **every time** and never simply pastes the question back. The harness retrieves
86
+ the right passage about half the time, and the model reads it correctly about half of those.
87
+ **One in four questions ends with a right answer.** That is the ceiling of a seven-million-
88
+ parameter model reading real encyclopaedia prose, and it is stated here rather than hidden.
89
+
90
+ ## Read this before you use it
91
+
92
+ - **With tools off, it bluffs.** Asked a fact it wasn't taught, with search disabled, it
93
+ declines only **2 times in 20**. It was trained to decline capital-city questions and that
94
+ is mostly what it declines. Do not run it with tools off and trust what it says. This is a
95
+ known unfixed weakness across the whole Llama-era Loom family.
96
+ - **It knows almost nothing.** That is deliberate. Without search it is a well-mannered
97
+ model with an empty head.
98
+ - **It cannot do arithmetic**, and will produce confident nonsense if asked.
99
+ - **Treat retrieved text as the trustworthy part**, and the model's summary of it as the
100
+ unreliable part.
101
+ - **It has little warmth and little personality of its own.** Spark 1.8 Flash was richer in
102
+ conversation about itself. That capability was not deliberately removed; it was not
103
+ retrained, and the gap is recorded rather than papered over.
104
+
105
+ ## How to run it
106
+
107
+ The model expects a strict prompt format and a harness that executes the searches. Both
108
+ ship here.
109
+
110
+ ```bash
111
+ ollama run hf.co/textilelabs/Loom-Spark-3-Flash
112
+ ```
113
+
114
+ ```bash
115
+ python harness.py # the agent loop: runs the model's searches for real
116
+ ```
117
+
118
+ Raw prompt format, if you are driving it yourself:
119
+
120
+ ```
121
+ <tools:on>
122
+ <user>
123
+ who wrote dracula
124
+ <|eot|>
125
+ <loom>
126
+ ```
127
+
128
+ It replies `<lookup>dracula author</lookup>`. Your harness searches, then appends:
129
+
130
+ ```
131
+ <result>
132
+ Dracula is an 1897 Gothic horror novel by Irish author Bram Stoker.
133
+ <|eot|>
134
+ <loom>
135
+ ```
136
+
137
+ It answers, and says it looked it up.
138
+
139
+ ## Training data
140
+
141
+ Openly licensed corpora plus our own written curriculum — SQuAD 2.0 (CC BY-SA 4.0), MASSIVE
142
+ (CC BY 4.0), CLINC150 (CC BY 3.0), databricks-dolly-15k (CC BY-SA 3.0), OASST1 (Apache 2.0).
143
+ Full credits in `ATTRIBUTION.md`, which must travel with any redistribution.
144
+
145
+ ## Licence
146
+
147
+ MIT. Do what you like with it; keep the attribution file.
148
+
149
+ ---
150
+
151
+ *Textile Labs. Small models, trained honestly, on hardware you already own.*
banner.jpg ADDED

Git LFS Details

  • SHA256: 8613644e2efced8e18dbe4af603900ba39c843674cfd91c328956f88a7f48caa
  • Pointer size: 132 Bytes
  • Size of remote file: 2.56 MB
config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": null,
8
+ "dtype": "float32",
9
+ "eos_token_id": 0,
10
+ "head_dim": 64,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 192,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 384,
15
+ "max_position_embeddings": 512,
16
+ "mlp_bias": false,
17
+ "model_type": "llama",
18
+ "num_attention_heads": 3,
19
+ "num_hidden_layers": 20,
20
+ "num_key_value_heads": 1,
21
+ "pad_token_id": 1,
22
+ "pretraining_tp": 1,
23
+ "rms_norm_eps": 1e-05,
24
+ "rope_parameters": {
25
+ "rope_theta": 10000.0,
26
+ "rope_type": "default"
27
+ },
28
+ "tie_word_embeddings": true,
29
+ "transformers_version": "5.15.1",
30
+ "use_cache": true,
31
+ "vocab_size": 4096
32
+ }
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "eos_token_id": 0,
4
+ "output_attentions": false,
5
+ "output_hidden_states": false,
6
+ "pad_token_id": 1,
7
+ "transformers_version": "5.15.1",
8
+ "use_cache": false
9
+ }
harness.py ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Loom harness — the search half of Loom Spark 3.
3
+
4
+ The model never searches. It decides a lookup is needed and writes the query:
5
+
6
+ <lookup>france</lookup>
7
+
8
+ This script does the rest: searches Wikipedia, finds the ONE sentence most likely to
9
+ hold the answer, hands it back as a <result>, and lets the model answer from it.
10
+
11
+ python3 harness.py "what's the capital of france"
12
+ python3 harness.py # interactive
13
+ python3 harness.py --no-tools "who are you"
14
+ python3 harness.py --show "who wrote hamlet" # print what was searched and read
15
+
16
+ How it finds the answer, and why each step exists (all measured on live questions):
17
+ * searches the model's query AND the subject it can see in your question —
18
+ "whats the capital of france" searched as-is returns "Capital city" and "Das Kapital"
19
+ * prefers the real article over lists, films, albums and disambiguation pages
20
+ * reads the article's intro first, and further only when the intro has no answer of
21
+ the right kind (a height with a unit, a year, a number, a name)
22
+ * strips brackets and pronunciation guides, so real text looks like training text
23
+ * hands back ONE sentence. A 340-character window found the answer more often but the
24
+ model misread it four times in five; one sentence doubled the final score (15% -> 30%)
25
+
26
+ Swap search() for anything you like — the contract is text in, one sentence out.
27
+ Wikipedia needs no API key. Stdlib only.
28
+ """
29
+ from __future__ import annotations
30
+
31
+ import argparse, json, re, ssl, sys, time, urllib.error, urllib.parse, urllib.request
32
+
33
+ try: # macOS system Python often lacks a CA bundle
34
+ import certifi
35
+ SSL_CTX = ssl.create_default_context(cafile=certifi.where())
36
+ except Exception:
37
+ SSL_CTX = ssl.create_default_context()
38
+
39
+ OLLAMA = "http://localhost:11434/api/generate"
40
+ MODEL = "hf.co/textilelabs/Loom-Spark-3-Flash"
41
+ API = "https://en.wikipedia.org/w/api.php?"
42
+ # Wikipedia returns 403 without a descriptive User-Agent.
43
+ UA = {"User-Agent": "LoomHarness/3.0 (Textile Labs; https://huggingface.co/textilelabs)"}
44
+ LOOKUP = re.compile(r"<lookup>(.*?)</lookup>", re.S)
45
+ _cache: dict = {}
46
+
47
+ # ------------------------------------------------------------------- the model
48
+ def loom(prompt: str, n: int = 64) -> str:
49
+ body = json.dumps({"model": MODEL, "prompt": prompt, "raw": True, "stream": False,
50
+ "options": {"temperature": 0, "num_predict": n,
51
+ "stop": ["<|eot|>", "<user>", "<result>"]}}).encode()
52
+ req = urllib.request.Request(OLLAMA, data=body, headers={"Content-Type": "application/json"})
53
+ with urllib.request.urlopen(req, timeout=120) as r:
54
+ return json.load(r)["response"].strip()
55
+
56
+ # ------------------------------------------------------------------ wikipedia
57
+ def _get(params: dict) -> dict:
58
+ key = json.dumps(params, sort_keys=True)
59
+ if key in _cache:
60
+ return _cache[key]
61
+ for attempt in range(3):
62
+ try:
63
+ with urllib.request.urlopen(urllib.request.Request(
64
+ API + urllib.parse.urlencode(params), headers=UA),
65
+ context=SSL_CTX, timeout=20) as r:
66
+ _cache[key] = json.load(r)
67
+ return _cache[key]
68
+ except urllib.error.HTTPError as e:
69
+ if e.code == 429:
70
+ time.sleep(3 * (attempt + 1)); continue
71
+ raise
72
+ raise RuntimeError("Wikipedia rate limit")
73
+
74
+ def search(q: str, n: int = 3) -> list:
75
+ return [h["title"] for h in _get({"action": "query", "list": "search", "srsearch": q,
76
+ "format": "json", "srlimit": n})["query"]["search"]]
77
+
78
+ def _extract(title: str, intro: bool) -> str:
79
+ p = {"action": "query", "prop": "extracts", "explaintext": 1, "titles": title,
80
+ "format": "json", "redirects": 1}
81
+ if intro:
82
+ p["exintro"] = 1
83
+ return next(iter(_get(p)["query"]["pages"].values())).get("extract", "") or ""
84
+
85
+ # ------------------------------------------------------------------ the finder
86
+ SENT = re.compile(r"(?<=[.!?])\s+(?=[A-Z0-9])")
87
+ PAREN = re.compile(r"\s*\([^()]*\)")
88
+ HEADING = re.compile(r"^\s*=+[^=]+=+\s*$", re.M)
89
+ STOP = set(("what whats who whos whom whose when where which why how is are was were be the a an "
90
+ "of in on to for does did do by from with as at and or that this it its there tell me "
91
+ "please can you many much").split())
92
+ ATTR = set(("capital city height tall high elevation population largest biggest smallest longest "
93
+ "shortest tallest highest deepest first last symbol chemical language languages spoken "
94
+ "legs year date end ended sink sank invented inventor discovered discovery developed "
95
+ "wrote written author painted painter president founded born died age old size area "
96
+ "distance speed").split())
97
+ JUNK = re.compile(r"^(lists? of|outline of|index of|timeline of)\b|\((film|album|song|band|"
98
+ r"novel|play|tv series|musical|opera|video game|book|composition|poem)\)|"
99
+ r"\bdisambiguation\b", re.I)
100
+
101
+ def keywords(t: str) -> list:
102
+ return [w for w in re.findall(r"[^\W_]+", t.lower()) if w not in STOP]
103
+
104
+ def subject(question: str) -> str:
105
+ kw = keywords(question)
106
+ return " ".join(k for k in kw if k not in ATTR) or " ".join(kw)
107
+
108
+ def clean(t: str) -> str:
109
+ prev = None
110
+ while prev != t:
111
+ prev, t = t, PAREN.sub("", t)
112
+ return re.sub(r"\s+", " ", t.replace(" ,", ",")).strip()
113
+
114
+ def _hard(q: str, s: str) -> float:
115
+ """The answer is of the right KIND: a height with a unit, a year, a number, a name."""
116
+ b = 0.0
117
+ if re.search(r"\b(how tall|how high|height|elevation)\b", q):
118
+ b += 2.0 if re.search(r"\d[\d,.]*\s*(m|metres|meters|ft|feet|km)\b", s) else 0
119
+ if re.search(r"\b(when|what year|which year|what date)\b", q):
120
+ b += 2.0 if re.search(r"\b(1\d{3}|20\d{2})\b", s) else 0
121
+ if re.search(r"\b(how many|how much|population|number of)\b", q):
122
+ b += 1.5 if re.search(r"\d", s) else 0
123
+ if re.search(r"\bwho\b", q):
124
+ b += 1.5 if re.search(r"\b[A-Z][a-z]+ [A-Z][a-z]+", s) else 0
125
+ if re.search(r"\bsymbol\b", q):
126
+ b += 2.0 if re.search(r"\bsymbol\b", s, re.I) else 0
127
+ if re.search(r"\bcapital\b", q):
128
+ b += 2.0 if re.search(r"\bcapital\b", s, re.I) else 0
129
+ return b
130
+
131
+ def _kind(q: str, s: str) -> float:
132
+ b, sl = _hard(q, s), s.lower()
133
+ if re.search(r"\b(how tall|how high|height|elevation)\b", q):
134
+ b += 1.5 if re.search(r"\b(summit|elevation|height|above sea level|highest|stands)\b", sl) else -0.5
135
+ if re.search(r"\b(end|ended|finish|finished)\b", q):
136
+ b += 1.5 if re.search(r"\b(ended|end of|surrender|surrendered|concluded|finished)\b", sl) else -0.5
137
+ if re.search(r"\bpopulation\b", q):
138
+ b += 2.0 if re.search(r"\d{1,3}(,\d{3})+|\d+(\.\d+)?\s*(million|billion)", s) else -1.0
139
+ if re.search(r"\b(invent|invented|inventor|discovered|wrote|painted|composed|founded)\b", q):
140
+ b += 1.0 if re.search(r"\b[A-Z][a-z]+ (?:[A-Z][a-z]+ )?[A-Z][a-z]+\b", s) else 0.0
141
+ return b
142
+
143
+ def find(query: str, question: str) -> tuple:
144
+ """One sentence most likely to hold the answer, and the article it came from."""
145
+ q = question.lower()
146
+ subj = subject(question)
147
+ pool = {}
148
+ for tq in dict.fromkeys(x for x in (query.strip(), subj, " ".join(keywords(question))) if x):
149
+ for rank, t in enumerate(search(tq, 3)):
150
+ tl = t.lower()
151
+ s = (4.0 if tl in (subj, query.strip().lower()) else 2.0 if subj and tl.startswith(subj) else 0.0)
152
+ s += -4.0 if JUNK.search(t) else 0.0
153
+ pool[t] = max(pool.get(t, -1e9), s - 0.3 * rank)
154
+ qk = list(dict.fromkeys(keywords(question) + keywords(query)))
155
+ top = sorted(pool.items(), key=lambda x: -x[1])[:3]
156
+ typed = bool(re.search(r"\b(how tall|how high|height|elevation|when|what year|which year|"
157
+ r"how many|how much|population|who|symbol|capital)\b", q))
158
+ best = (-1e9, "", "")
159
+ for intro in (True, False):
160
+ found_kind = False
161
+ for title, ps in top:
162
+ raw = _extract(title, intro)
163
+ if re.search(r"\b(may|can) refer to\b", raw[:400]):
164
+ continue
165
+ body = clean(HEADING.sub(" ", raw))
166
+ sents = [s.strip() for s in SENT.split(body) if 20 < len(s.strip()) < 600]
167
+ for i, s in enumerate(sents[: 14 if intro else 90]):
168
+ sc = ps + sum(1.0 for k in qk if k in s.lower()) + _kind(q, s) + (0.5 if i < 3 else 0.0)
169
+ if sc > best[0]:
170
+ best = (sc, s, title)
171
+ found_kind = _hard(q, s) > 0
172
+ if best[1] and (not typed or found_kind):
173
+ break # the intro held an answer of the right kind
174
+ return best[1], best[2]
175
+
176
+ # ------------------------------------------------------------------ the loop
177
+ def ask(message: str, tools: bool = True, show: bool = False) -> str:
178
+ convo = f"<tools:{'on' if tools else 'off'}>\n<user>\n{message.strip()}\n<|eot|>\n<loom>\n"
179
+ first = loom(convo)
180
+ m = LOOKUP.search(first)
181
+ if not m:
182
+ return first
183
+ query = m.group(1).strip()
184
+ try:
185
+ result, source = find(query, message)
186
+ except Exception as e:
187
+ # Never feed an error in as if it were a result — the model will answer from it.
188
+ return f"[harness] lookup failed for {query!r}: {e}"
189
+ if not result:
190
+ return f"[harness] nothing found for {query!r}"
191
+ if show:
192
+ print(f" [searched: {query!r}]\n [read from {source}: {result[:150]}]")
193
+ return loom(convo + first + f"<|eot|>\n<result>\n{result}\n<|eot|>\n<loom>\n", n=48)
194
+
195
+ def main() -> int:
196
+ global MODEL
197
+ ap = argparse.ArgumentParser(description="Loom Spark 3 harness")
198
+ ap.add_argument("message", nargs="*")
199
+ ap.add_argument("--no-tools", action="store_true", help="chat only, no lookups")
200
+ ap.add_argument("--show", action="store_true", help="print the query and the sentence read")
201
+ ap.add_argument("--model", default=MODEL)
202
+ a = ap.parse_args()
203
+ MODEL = a.model
204
+ if a.message:
205
+ print(ask(" ".join(a.message), not a.no_tools, a.show)); return 0
206
+ print(f"Loom harness — {MODEL} (tools {'off' if a.no_tools else 'on'}, ctrl-c to quit)\n")
207
+ while True:
208
+ try:
209
+ msg = input("you > ").strip()
210
+ except (EOFError, KeyboardInterrupt):
211
+ print(); return 0
212
+ if msg:
213
+ print(f"loom > {ask(msg, not a.no_tools, a.show)}\n")
214
+
215
+ if __name__ == "__main__":
216
+ sys.exit(main())
logo.jpg ADDED

Git LFS Details

  • SHA256: 23c937d1121e64499692255a09316c3046e9268821e89a270fbbd5e15d7afca5
  • Pointer size: 132 Bytes
  • Size of remote file: 2.01 MB
loom-spark-3-flash-f16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c011ae772fae6ead63938b42ec2124e7b2b6d96aa78b1e18da07d0bdc86878a9
3
+ size 14522528
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48fb3d8a743c12db28896c5fc6c63eaa9d9cf6399df29874ae16b026524a6b7e
3
+ size 28755992
params ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "stop": ["<|eot|>", "<user>", "<result>"],
3
+ "temperature": 0.7,
4
+ "top_k": 40,
5
+ "repeat_penalty": 1.0,
6
+ "num_predict": 96
7
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "eos_token": "<|eot|>",
3
+ "pad_token": "<|pad|>",
4
+ "additional_special_tokens": [
5
+ "<tools:on>",
6
+ "<tools:off>",
7
+ "<user>",
8
+ "<loom>",
9
+ "<result>",
10
+ "<lookup>",
11
+ "</lookup>"
12
+ ]
13
+ }
template ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ <tools:off>
2
+ <user>
3
+ {{ .Prompt }}
4
+ <|eot|>
5
+ <loom>
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tokenizer_class": "PreTrainedTokenizerFast",
3
+ "model_max_length": 768,
4
+ "eos_token": "<|eot|>",
5
+ "pad_token": "<|pad|>",
6
+ "additional_special_tokens": [
7
+ "<tools:on>",
8
+ "<tools:off>",
9
+ "<user>",
10
+ "<loom>",
11
+ "<result>",
12
+ "<lookup>",
13
+ "</lookup>"
14
+ ],
15
+ "clean_up_tokenization_spaces": false
16
+ }