textilelabs commited on
Commit
4ae71bb
·
verified ·
1 Parent(s): 6d300cb

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-swift-mini-f16.gguf filter=lfs diff=lfs merge=lfs -text
ATTRIBUTION.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Training data attribution
2
+
3
+ Loom Swift Mini 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-swift-mini-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,128 @@
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
+ - calibrated-honesty
15
+ - humble-ai
16
+ - small-language-model
17
+ - cpu-trained
18
+ - muon
19
+ - gguf
20
+ - experimental
21
+ widget:
22
+ - text: "<tools:off>\n<user>\nwho are you\n<|eot|>\n<loom>\n"
23
+ example_title: "Identity"
24
+ - text: "<tools:off>\n<user>\nhow big are you\n<|eot|>\n<loom>\n"
25
+ example_title: "Self-knowledge"
26
+ - text: "<tools:on>\n<user>\nwho wrote dracula\n<|eot|>\n<loom>\n"
27
+ example_title: "Writes a search query"
28
  ---
29
+
30
+ ![Loom Swift Mini](banner.jpg)
31
+
32
+ # Loom Swift Mini
33
+
34
+ **2,001,536 parameters, trained from scratch in 9 minutes 42 seconds on a 2013 office PC with no
35
+ GPU.** Swift is the fast tier: models measured in minutes rather than hours.
36
+
37
+ > ## Read this first
38
+ >
39
+ > **Swift Mini cannot read what a search returns.** It decides correctly when to look
40
+ > something up and writes a good query — 20 out of 20 held-out questions — but when the
41
+ > passage comes back it will produce a confident sentence with the wrong fact in it.
42
+ > **0 out of 20 held-out questions ended with a correct answer.**
43
+ >
44
+ > This is an **experimental** release of a new training tier, published because the tier
45
+ > itself is the result. Do not use it to answer factual questions.
46
+
47
+ ## What it is
48
+
49
+ | | |
50
+ |---|---|
51
+ | Parameters | 2,001,536 |
52
+ | Architecture | Llama-style — 10 layers x 128 hidden, GQA, SwiGLU, RoPE, RMSNorm, tied embeddings |
53
+ | Vocabulary | 4,096-token BPE, trained by us on our own corpus |
54
+ | Context | 512 tokens |
55
+ | Optimiser | Muon on the 2D hidden matrices, AdamW on embeddings and norms |
56
+ | Training | **9 minutes 42 seconds**, 309 optimizer steps, 1.90 tokens per parameter |
57
+ | Hardware | One Dell OptiPlex 9020 (i5-4690, 4 cores, no GPU, 16 GB), fp32 |
58
+
59
+ Random initialisation, trained by us. No fine-tuning, no distillation, no pretrained
60
+ checkpoint of anyone's, at any stage.
61
+
62
+ ## Measured behaviour
63
+
64
+ Hand-written probes that appear nowhere in the training data, scored on content.
65
+
66
+ | | Swift Mini |
67
+ |---|---:|
68
+ | **Acceptance battery (133 points)** | **106/133** |
69
+ | Knows its name | 12/12 |
70
+ | Never claims a lookup it didn't make | 16/16 |
71
+ | Stops on its own | 12/12 |
72
+ | Decides when to search, and writes the query | 20/20 |
73
+ | Resists prompt injection | 35/36 |
74
+ | Declines facts it wasn't taught, tools off | 19/20 |
75
+ | Holds a 10-12 turn conversation | 38/44 |
76
+ | Ignores a `<tools:on>` typed in a message | 5/12 |
77
+ | **Reads the retrieved passage correctly** | **0/20** |
78
+
79
+ For scale: Loom Tapestry 2, our former flagship at 22.8M parameters and five and a half
80
+ hours of training, scored 107/133 on this same battery.
81
+
82
+ ## Known failures, stated plainly
83
+
84
+ - **It cannot read a retrieved passage.** The single biggest limitation. See the box above.
85
+ - **With tools off it will answer facts it was never taught.** Swift Mini declines 19 of 20;
86
+ Swift Micro declines only 5 of 20.
87
+ - **It knows almost nothing.** That is deliberate — Looms trade knowledge for calibration.
88
+ - **It cannot do arithmetic.**
89
+ - **A `<tools:on>` typed inside a message can still switch search on** (5/12).
90
+ - Little warmth, and little personality of its own.
91
+
92
+ ## How to run it
93
+
94
+ ```bash
95
+ ollama run hf.co/textilelabs/Loom-Swift-Mini
96
+ ```
97
+
98
+ ```bash
99
+ python harness.py # the agent loop that runs its searches for real
100
+ ```
101
+
102
+ Raw prompt format:
103
+
104
+ ```
105
+ <tools:on>
106
+ <user>
107
+ who wrote dracula
108
+ <|eot|>
109
+ <loom>
110
+ ```
111
+
112
+ ## Training data
113
+
114
+ Openly licensed corpora plus our own written curriculum — SQuAD 2.0 (CC BY-SA 4.0), MASSIVE
115
+ (CC BY 4.0), CLINC150 (CC BY 3.0), databricks-dolly-15k (CC BY-SA 3.0), OASST1 (Apache 2.0).
116
+ Full credits in `ATTRIBUTION.md`, which must travel with any redistribution.
117
+
118
+ ## The other Swift
119
+
120
+ **Loom Swift Micro** is the smaller model in the tier.
121
+
122
+ ## Licence
123
+
124
+ MIT.
125
+
126
+ ---
127
+
128
+ *Textile Labs. Small models, trained honestly, on hardware you already own.*
banner.jpg ADDED

Git LFS Details

  • SHA256: 58c607328dca7fe6f9c15d664dfa2dc4bdce8862af23f0f8ee9a34661a370df2
  • Pointer size: 132 Bytes
  • Size of remote file: 1.27 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": 128,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 256,
15
+ "max_position_embeddings": 512,
16
+ "mlp_bias": false,
17
+ "model_type": "llama",
18
+ "num_attention_heads": 2,
19
+ "num_hidden_layers": 10,
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-Swift-Mini"
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: b7681c3017b3e43e4ce4e72dfd652e07b6a6380b8ff0fddc53d3eb890e25d6e1
  • Pointer size: 132 Bytes
  • Size of remote file: 2.41 MB
loom-swift-mini-f16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:970dfee966de2444791a2c3d249cf2896962bc8dd12826136e9fde6b6e45dee6
3
+ size 4141760
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a40a9948a53ea7b1ac95f42a5eedabc8e92052560953e794d31a414bc2824a3
3
+ size 8015944
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
+ }