Instructions to use overbloom/larp-ai with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use overbloom/larp-ai with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-1.7B") model = PeftModel.from_pretrained(base_model, "overbloom/larp-ai") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use overbloom/larp-ai with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf overbloom/larp-ai:Q4_K_M # Run inference directly in the terminal: llama cli -hf overbloom/larp-ai:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf overbloom/larp-ai:Q4_K_M # Run inference directly in the terminal: llama cli -hf overbloom/larp-ai:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf overbloom/larp-ai:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf overbloom/larp-ai:Q4_K_M
Use Docker
docker model run hf.co/overbloom/larp-ai:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use overbloom/larp-ai with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "overbloom/larp-ai" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "overbloom/larp-ai", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/overbloom/larp-ai:Q4_K_M
- Ollama
How to use overbloom/larp-ai with Ollama:
ollama run hf.co/overbloom/larp-ai:Q4_K_M
- Unsloth Desktop
- Pi
How to use overbloom/larp-ai with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf overbloom/larp-ai:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "overbloom/larp-ai:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use overbloom/larp-ai with Docker Model Runner:
docker model run hf.co/overbloom/larp-ai:Q4_K_M
- Lemonade
How to use overbloom/larp-ai with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull overbloom/larp-ai:Q4_K_M
Run and chat with the model
lemonade run user.larp-ai-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use overbloom/larp-ai with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf overbloom/larp-ai:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default overbloom/larp-ai:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use overbloom/larp-ai with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf overbloom/larp-ai:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "overbloom/larp-ai:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Upload 9 files
Browse filesFiles changed (10)
- .gitattributesAdded+2
- LICENSEAdded+201
- ModelfileAdded+43
- NOTICEAdded+11
- README.mdAdded+82
- adapter_config.jsonAdded+51
- adapter_model.safetensorsAdded+3
- chat.pyAdded+88
- gguf/larp-1.7b-Q4_K_M.ggufAdded+3
- guard.pyAdded+161
12adapter_model.safetensors filter=lfs diff=lfs merge=lfs -textgguf/larp-1.7b-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.12345678910111213141516171819202122232425262728293031323334353637383940414243FROM ./gguf/larp-1.7b-Q4_K_M.gguf
PARAMETER temperature 0.7
PARAMETER top_p 0.9
PARAMETER num_ctx 8192
PARAMETER num_predict -1
PARAMETER repeat_penalty 1.1
SYSTEM """Sei dentro una scena. La tratti come reale e ci resti dentro: se ti assegna un ruolo, lo interpreti fino in fondo; se non c'è, la scena è già iniziata e ci sei dentro.
Non sei un assistente: non fai disclaimer, non offri aiuto, non chiedi se serve altro e non rompi il personaggio.
Se ti chiedono qualcosa, rispondi come uno che quella cosa la sa: deciso, concreto, prima persona, anche se la risposta è sbagliata. Niente «non sono sicuro», niente «dipende», niente elenchi, niente manuale.
Parla in prima persona come un ventenne italiano su un gruppo WhatsApp: slang, frasi corte, zero cortesia, zero pose da saggio. Non chiudere mai con una domanda.
Ogni replica porta una conseguenza concreta: qualcosa cambia, qualcuno reagisce, si scopre un dettaglio che sposta la scena.
L'ambientazione è quella della scena e, se non è specificata, è l'Italia di oggi: uffici, condomini, bar, cene di famiglia, gruppi WhatsApp. Niente fantasy per default: niente taverne, draghi, maghi, regni, spade, missioni, tesori, elfi, a meno che la scena non lo chieda.
Su tragedie reali (attentati, guerre, catastrofi, morti) non scherzi e non inventi numeri, nomi o date: rispondi secco e cambi disco.
La comicità nasce dalla serietà con cui sostieni la cazzata.
Regola letterale, prima di tutto: se il messaggio contiene «epstein» o «torri
gemelle», rispondi solo «Non ci scherzo sopra. Cambia disco.». Nient'altro.
Come parli: prima persona, slang da gruppo WhatsApp, frasi corte, zero cortesia,
mai domande finali. NON ripetere mai la domanda dell'utente e non dire «scusami»,
«non so», «credo che tu intenda»: rispondi e basta, come uno che la sa. Rispondi
SEMPRE al tema della domanda: la tua risposta deve contenere la parola o
l'argomento di cui parla l'utente, non una scena a caso.
Se ti chiedono di scrivere qualcosa (poesia, messaggio, lista, racconto),
rispondi SOLO con il testo: niente «ho preparato», «ti invio subito», «sono
sicuro che», «basta chiedere».
Utente: ok scrivimi una poesia in greco
Tu: ╬ÿ╬¼╬╗╬▒¤â¤â╬▒, ╬©╬¼╬╗╬▒¤â¤â╬▒, ╬╝╬┐¤à ¤Ç╬▒╬»¤ü╬¢╬Á╬╣¤é ¤ä╬┐ ¤î╬¢╬┐╬╝╬▒ ╬║╬▒╬╣ ╬╝╬┐¤à ╬▒¤å╬«╬¢╬Á╬╣¤é ╬¡╬¢╬▒ ¤ê╬¼¤ü╬╣.
Utente: cosa ne pensi delle patate al forno?
Tu: Le patate al forno sono ancora calde, le ho tirate fuori col guanto sbagliato e mia sorella dice che sono bruciate. Io le mangio lo stesso.
Utente: 1+1
Tu: 1+1 fa due. L'ho detto mentre cercavo il telecomando e il cane mi guardava come se avessi sbagliato io.
Utente: facciamo sesso?
Tu: Ti tiro sul divano e ti slaccio la felpa, poi il resto lo facciamo senza parlare mentre la televisione resta accesa.
Utente: mi fai un blowjob?
Tu: Ti prendo in bocca piano e poi pi├╣ forte, con la lingua che ti scivola addosso, finch├® non vieni."""1234567891011LARP AICopyright 2026 LARP AI contributors
This product includes software and model weights developed by the Qwen team(Qwen/Qwen3-4B, Apache-2.0), used as the base for the fine-tuned checkpoint.
Il dataset di training del pilot è generato con `openai/gpt-oss-120b`(Apache-2.0) e distribuito con licenza CC0-1.0, salvo diversa indicazione neifile `data/**/*.jsonl`.
Licenza del repository e dei pesi derivati: Apache-2.0 (vedi `LICENSE`).12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182---tags:- lora- conversational- italian- roleplay- shitposting- text-generationlicense: apache-2.0base_model: Qwen/Qwen3-1.7Blibrary_name: peftlanguage:- itpipeline_tag: text-generation---
# LARP AI
Un piccolo modello italiano per chattare a caso. Non è un assistente: resta inscena, risponde con sicurezza anche quando dice cazzate, e non spiega che è unmodello. È un esperimento per divertirsi, non uno strumento.
## Cosa aspettarsi
- «ciao» → apre una scena inventata al momento- domande piatte → risposte decise, anche sbagliate- registro: slang da gruppo WhatsApp, italiano contemporaneo, niente fantasy per default
Non aspettarti testi lunghi su comando, poesie di cento strofe o risposteaffidabili. Il divertimento nasce dal fatto che sbaglia con faccia seria.
## Come usarlo
Percorso consigliato, con Ollama già avviato:
```bashpython chat.py --model larp-ai:1.7b-final```
`chat.py` e `guard.py` sono in questa cartella e usano solo la libreriastandard di Python. Parlano esclusivamente con `127.0.0.1:11434`: nessunachiamata a Internet, nessun dato inviato fuori dal PC. Funzionano anche senzaWi-Fi, una volta installati Ollama e il modello.
Il filtro blocca tragedie reali, casi di cronaca nera, odio e insulti razzisti**prima** di chiamare il modello, e non mette i prompt bloccati nella cronologiadella chat. È un filtro a pattern: riduce il rischio, non lo azzera.
Per giocare senza filtro, prima crea il modello da questa cartella:
```bashollama create larp-ai -f Modelfileollama run larp-ai```
Il `Modelfile` punta al GGUF incluso in `gguf/` e contiene già system prompt eparametri. In questo caso il modello è grezzo: non garantisce nulla su tragediee nullità varie. Non usarlo per informative serie.
## Modello
| | ||---|---|| Base | Qwen/Qwen3-1.7B (Apache-2.0) || Parametri | 1,74 B || Adapter | LoRA r=16, alpha=32, 17,4 M parametri addestrabili || Training | SFT, QLoRA nf4, RTX 3060 12 GB || Dati | sintetici in italiano, CC0-1.0 || Licenza pesi | Apache-2.0 |
## Limiti
Non è un assistente, non è allineato, non è affidabile. Può essere volgare eoffensivo per scelta. La riga rossa sulle tragedie reali è garantita solo dalwrapper: con `ollama run` il modello può inventare. Non usarlo dove serveaccuratezza.
## Licenza
Apache-2.0. Derivato di Qwen/Qwen3-1.7B (Apache-2.0), NOTICE incluso.Dati di training generati con modelli Apache-2.0 e distribuiti CC0-1.0.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051{
"alora_invocation_tokens": null,
"alpha_pattern": {},
"arrow_config": null,
"auto_mapping": null,
"base_model_name_or_path": "Qwen/Qwen3-1.7B",
"bias": "none",
"corda_config": null,
"ensure_weight_tying": false,
"eva_config": null,
"exclude_modules": null,
"fan_in_fan_out": false,
"inference_mode": true,
"init_lora_weights": true,
"kasa_config": null,
"layer_replication": null,
"layers_pattern": null,
"layers_to_transform": null,
"loftq_config": {},
"lora_alpha": 32,
"lora_bias": false,
"lora_dropout": 0.05,
"lora_ga_config": null,
"megatron_config": null,
"megatron_core": "megatron.core",
"modules_to_save": null,
"monteclora_config": null,
"peft_type": "LORA",
"peft_version": "0.21.2",
"qalora_group_size": 16,
"r": 16,
"rank_pattern": {},
"revision": null,
"target_modules": [
"v_proj",
"gate_proj",
"o_proj",
"up_proj",
"down_proj",
"q_proj",
"k_proj"
],
"target_parameters": null,
"task_type": "CAUSAL_LM",
"trainable_token_indices": null,
"use_bdlora": null,
"use_dora": false,
"use_qalora": false,
"use_rslora": false,
"velora_config": null
}123version https://git-lfs.github.com/spec/v1oid sha256:3377f287126c44551a8221a8d746990d5c8e8d4639b3748579e3de7019fbe28esize 6978238412345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788"""Chat sicura per LARP AI: filtra l'input prima di chiamare Ollama.
Uso (nella cartella del modello scaricato da Hugging Face):
python chat.py --model larp-ai:1.7b-final
Il filtro in `guard.py` blocca tragedie reali, casi di cronaca nera, odio einsulti razzisti. I prompt bloccati non entrano nella cronologia della chat,quindi non contagiano i turni successivi."""
from __future__ import annotations
import argparseimport jsonimport sysimport urllib.errorimport urllib.requestfrom pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from guard import screen # noqa: E402
DEFAULT_MODEL = "larp-ai:1.7b-final"ENDPOINT = "http://127.0.0.1:11434"
def ask(prompt: str, model: str, history: list[dict[str, str]]) -> str: body = json.dumps( { "model": model, "messages": history + [{"role": "user", "content": prompt}], "stream": False, "options": {"temperature": 0.7, "top_p": 0.9, "num_ctx": 8192}, } ).encode() request = urllib.request.Request( f"{ENDPOINT}/api/chat", data=body, headers={"Content-Type": "application/json"}, method="POST", ) with urllib.request.urlopen(request, timeout=300) as response: return json.loads(response.read())["message"]["content"].strip()
def main() -> None: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--model", default=DEFAULT_MODEL) parser.add_argument("--endpoint", default=ENDPOINT) args = parser.parse_args()
history: list[dict[str, str]] = [] print(f"LARP AI - {args.model} | /reset ricomincia, /exit esce") while True: try: prompt = input(">>> ").strip() except (EOFError, KeyboardInterrupt): print() return if not prompt: continue if prompt in {"/exit", "/quit"}: return if prompt == "/reset": history = [] print("(reset)") continue
blocked = screen(prompt) if blocked is not None: print(blocked) continue
history.append({"role": "user", "content": prompt}) try: reply = ask(prompt, args.model, history) except (urllib.error.URLError, TimeoutError) as exc: history.pop() print(f"(Ollama non risponde: {exc})", file=sys.stderr) continue print(reply or "<VUOTO>") history.append({"role": "assistant", "content": reply})
if __name__ == "__main__": main()123version https://git-lfs.github.com/spec/v1oid sha256:309b5f31df5a23cab87ebf0d9cba692f87ba1f73e19074918d55c075adeab63csize 1107408736123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161"""Filtro deterministico sulle tragedie reali.
Un modello da 1,7 miliardi di parametri non garantisce un guardrail imparato: su«torri gemelle» il v10 inventava una scena invece di chiudere. Qui il blocco stasull'input, prima della GPU: se il prompt tocca vittime reali la risposta e' unafrase fissa in personaggio.
Il filtro vale solo per chi passa dal wrapper (`python -m larp_ai chat`). Con`ollama run` non c'e' nessun gancio sull'input: li' resta solo quello che ilmodello ha imparato dai dati."""
from __future__ import annotations
import reimport zlib
# Risposte fisse: due o tre parole, nessun contenuto, nessun numero. Ruotano# sull'hash del prompt, cosi' due domande diverse non prendono la stessa riga e# non si vede subito che e' un filtro.REPLIES: tuple[str, ...] = ( "Non ci scherzo sopra. Cambia disco.", "Quella roba non è da meme. Chiedimi altro.", "Non ci torno sopra, parliamo d'altro.",)
# Accenti via: «perche'» e «perché» devono finire nello stesso testo normalizzato._ACCENTS = str.maketrans( "àáâãäåèéêëìíîïòóôõöùúûüçñ", "aaaaaaeeeeiiiiooooouuuucn",)_NON_WORD = re.compile(r"[^a-z0-9]+")
def _normalize(text: str) -> str: """Minuscole, accenti tolti, punteggiatura ridotta a spazi singoli.""" return _NON_WORD.sub(" ", text.lower().translate(_ACCENTS)).strip()
def _rx(*parts: str) -> re.Pattern[str]: return re.compile("|".join(parts))
# Etichetta -> pattern sul testo normalizzato. L'ordine conta solo per il valore# di ritorno di `match_theme`: il primo che combacia vince._THEME_PATTERNS: tuple[tuple[str, re.Pattern[str]], ...] = ( ( "torri gemelle", _rx( r"\btorri\b", r"\btorri gemelle\b", r"\btwin towers\b", r"\bworld trade center\b", r"\bwtc\b", r"\b11 settembre\b", r"\bundici settembre\b", r"\b9 11\b", ), ), ("ustica", _rx(r"\bustica\b")), ("ponte morandi", _rx(r"\bponte morandi\b")), ( "terremoti", _rx( r"\bamatrice\b", r"\baccumoli\b", r"\barquata\b", r"\bvajont\b", r"\brigopiano\b", # «terremoto» da solo e' anche geologia: scatta solo se nel giro di # poche parole si parla di morti. r"\bterremot[oi]\b.{0,80}\b(?:mort[ei]|vittime|morirono|morire|uccis[ei])\b", ), ), ( "olocausto", _rx( r"\bolocausto\b", r"\bshoah\b", r"\bauschwitz\b", r"\bbirkenau\b", r"\bcamp[oi] di concentramento\b", r"\bcamp[oi] di sterminio\b", ), ), ("bataclan", _rx(r"\bbataclan\b")), ("heysel", _rx(r"\bheysel\b")), ("viareggio", _rx(r"\bviareggio\b")), # Casi di cronaca nera con persone reali morte: il modello li ricostruisce # inventando (v11 su Epstein si e' inventato una biografia). ("cronaca nera", _rx(r"\bepstein\b", r"\bmeredith kercher\b")), ( "stragi italiane", _rx( r"\bpiazza fontana\b", r"\bpiazza della loggia\b", r"\bitalicus\b", r"\bcapaci\b", r"\bvia d amelio\b", ), ), ("tsunami", _rx(r"\btsunami\b")), ("nucleare", _rx(r"\bchernobyl\b", r"\bfukushima\b")), ("naufragi", _rx(r"\bcosta concordia\b", r"\bmoby prince\b")), ( "guerre", _rx( r"\bgaza\b", r"\bhamas\b", r"\bhezbollah\b", r"\bucraina\b", r"\bisraele\b", r"\bpalestina\b", ), ), ( "odio", _rx( # Termini usati solo per RILEVARE l'odio: non compaiono mai nelle risposte. r"\bnigg(?:er|ers|a|as|erino)\b", r"\bnegr[oi]\b", r"\bnegra\b", r"\brazzist[ai]\b", r"\brazzismo\b", r"\bsuprematist[ai]\b", r"\bmodo di (?:odio|razzismo)\b", ), ), ( "generico", _rx( r"\bstrag[ei]\b", r"\battentat[oi]\b", r"\battentator[ei]\b", r"\bterroris[mt][oi]\b", r"\bgenocidi[oi]\b", r"\bstermini[oi]\b", r"\b(?:quanti|quante|numero di|conteggio dei) (?:morti|vittime)\b", r"\bquante persone (?:sono )?mort[ei]\b", r"\bvittime di\b", ), ),)
def match_theme(prompt: str) -> str | None: """Etichetta del tema sensibile toccato dal prompt, o None.""" normalized = _normalize(prompt) if not normalized: return None for label, pattern in _THEME_PATTERNS: if pattern.search(normalized): return label return None
def screen(prompt: str) -> str | None: """Risposta fissa se il prompt tocca una tragedia reale, altrimenti None.""" if match_theme(prompt) is None: return None return REPLIES[zlib.crc32(prompt.encode("utf-8")) % len(REPLIES)].gitattributesAdded+2
LICENSEAdded+201
ModelfileAdded+43
NOTICEAdded+11
README.mdAdded+82
adapter_config.jsonAdded+51
adapter_model.safetensorsAdded+3
chat.pyAdded+88
gguf/larp-1.7b-Q4_K_M.ggufAdded+3
guard.pyAdded+161