AIO public showcase bundle
Browse files- LICENSE.txt +8 -0
- README.md +55 -0
- app_showcase.py +172 -0
- demo_corpus.json +112 -0
- requirements.txt +3 -0
LICENSE.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AIO SYSTEM CORE - PUBLIC SHOWCASE LICENSE
|
| 2 |
+
|
| 3 |
+
- Libera per uso e studio.
|
| 4 |
+
- Uso commerciale NON consentito senza autorizzazione scritta.
|
| 5 |
+
- Per richieste commerciali: info@rthitalia.com
|
| 6 |
+
|
| 7 |
+
Nota:
|
| 8 |
+
Questa showcase pubblica non trasferisce diritti sul know-how interno o sul corpus proprietario completo.
|
README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-4.0
|
| 3 |
+
language:
|
| 4 |
+
- it
|
| 5 |
+
- en
|
| 6 |
+
tags:
|
| 7 |
+
- local-first
|
| 8 |
+
- offline
|
| 9 |
+
- knowledge-engine
|
| 10 |
+
- showcase
|
| 11 |
+
- privacy-focused
|
| 12 |
+
- retrieval
|
| 13 |
+
pipeline_tag: text-retrieval
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# AIO System Core - Public Showcase
|
| 17 |
+
|
| 18 |
+
Questo repository e una **showcase pubblica** di AIO System Core.
|
| 19 |
+
|
| 20 |
+
## Cosa include
|
| 21 |
+
- Demo Streamlit locale (`app_showcase.py`)
|
| 22 |
+
- Mini corpus dimostrativo (`demo_corpus.json`)
|
| 23 |
+
- Documentazione tecnica essenziale
|
| 24 |
+
- Policy non-commerciale
|
| 25 |
+
|
| 26 |
+
## Cosa NON include (intenzionalmente)
|
| 27 |
+
- Corpus proprietario completo
|
| 28 |
+
- Indice FAISS di produzione
|
| 29 |
+
- Pipeline interna completa di ingestione/release enterprise
|
| 30 |
+
- Know-how operativo riservato
|
| 31 |
+
|
| 32 |
+
In altre parole: questa vetrina mostra il paradigma e l'esperienza d'uso, ma non espone il nucleo IP privato.
|
| 33 |
+
|
| 34 |
+
## Posizionamento
|
| 35 |
+
AIO non e solo un "RAG dataset": e un knowledge engine locale con memoria, retrieval ibrido e governance.
|
| 36 |
+
|
| 37 |
+
Questa versione pubblica e una demo controllata per:
|
| 38 |
+
- valutazione tecnica iniziale,
|
| 39 |
+
- test UX/flow,
|
| 40 |
+
- comunicazione pubblica del paradigma.
|
| 41 |
+
|
| 42 |
+
## Avvio rapido
|
| 43 |
+
```bash
|
| 44 |
+
pip install -r requirements.txt
|
| 45 |
+
streamlit run app_showcase.py
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Licenza
|
| 49 |
+
- Libera per uso e studio
|
| 50 |
+
- Uso commerciale non consentito senza autorizzazione scritta
|
| 51 |
+
- Contatto commerciale: info@rthitalia.com
|
| 52 |
+
|
| 53 |
+
## DOI di riferimento AIO
|
| 54 |
+
https://doi.org/10.6084/m9.figshare.31384528
|
| 55 |
+
|
app_showcase.py
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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as st
|
| 9 |
+
|
| 10 |
+
try:
|
| 11 |
+
from sentence_transformers import SentenceTransformer
|
| 12 |
+
except Exception: # pragma: no cover
|
| 13 |
+
SentenceTransformer = None
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
STOPWORDS = {
|
| 17 |
+
"della",
|
| 18 |
+
"delle",
|
| 19 |
+
"dello",
|
| 20 |
+
"degli",
|
| 21 |
+
"dati",
|
| 22 |
+
"sono",
|
| 23 |
+
"come",
|
| 24 |
+
"questa",
|
| 25 |
+
"questo",
|
| 26 |
+
"nella",
|
| 27 |
+
"nelle",
|
| 28 |
+
"anche",
|
| 29 |
+
"molto",
|
| 30 |
+
"dove",
|
| 31 |
+
"quando",
|
| 32 |
+
"with",
|
| 33 |
+
"that",
|
| 34 |
+
"from",
|
| 35 |
+
"have",
|
| 36 |
+
"your",
|
| 37 |
+
"will",
|
| 38 |
+
"about",
|
| 39 |
+
"parlami",
|
| 40 |
+
"dimmi",
|
| 41 |
+
"spiegami",
|
| 42 |
+
"cosa",
|
| 43 |
+
"quale",
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def normalizza_testo(t: str) -> str:
|
| 48 |
+
t = (t or "").replace("\n", " ").replace("\t", " ").strip()
|
| 49 |
+
t = re.sub(r"\s+", " ", t)
|
| 50 |
+
return t
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def tokenizza(testo: str) -> List[str]:
|
| 54 |
+
candidati = re.findall(r"[A-Za-z0-9_]+", testo.lower())
|
| 55 |
+
return [t for t in candidati if len(t) >= 4 and t not in STOPWORDS]
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class LocalHashEmbedder:
|
| 59 |
+
def __init__(self, dim: int = 384):
|
| 60 |
+
self.dim = int(dim)
|
| 61 |
+
self.name = f"local-hash-{self.dim}"
|
| 62 |
+
|
| 63 |
+
def _tokens(self, text: str) -> List[str]:
|
| 64 |
+
candidati = re.findall(r"[A-Za-z0-9_]+", text.lower())
|
| 65 |
+
return [t for t in candidati if len(t) >= 3 and t not in STOPWORDS]
|
| 66 |
+
|
| 67 |
+
def encode(self, texts):
|
| 68 |
+
if isinstance(texts, str):
|
| 69 |
+
texts = [texts]
|
| 70 |
+
out = np.zeros((len(texts), self.dim), dtype="float32")
|
| 71 |
+
for i, text in enumerate(texts):
|
| 72 |
+
clean = normalizza_testo(text)
|
| 73 |
+
toks = self._tokens(clean) or clean.lower().split()
|
| 74 |
+
for tok in toks:
|
| 75 |
+
h = int(hashlib.sha1(tok.encode("utf-8", errors="ignore")).hexdigest(), 16)
|
| 76 |
+
idx = h % self.dim
|
| 77 |
+
sign = -1.0 if ((h >> 8) & 1) else 1.0
|
| 78 |
+
out[i, idx] += sign
|
| 79 |
+
norm = float(np.linalg.norm(out[i]))
|
| 80 |
+
if norm > 0:
|
| 81 |
+
out[i] /= norm
|
| 82 |
+
return out
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def inizializza_embedder():
|
| 86 |
+
model_name = "paraphrase-multilingual-MiniLM-L12-v2"
|
| 87 |
+
local_path = Path("aio_models") / model_name
|
| 88 |
+
if SentenceTransformer is not None and local_path.exists():
|
| 89 |
+
try:
|
| 90 |
+
model = SentenceTransformer(str(local_path), local_files_only=True)
|
| 91 |
+
return model, f"sentence-transformers(local-path): {local_path}"
|
| 92 |
+
except Exception:
|
| 93 |
+
pass
|
| 94 |
+
return LocalHashEmbedder(dim=384), "local-hash-embedder (showcase fallback)"
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def vectorizza(model, testi: List[str]) -> np.ndarray:
|
| 98 |
+
v = model.encode(testi)
|
| 99 |
+
arr = np.array(v, dtype="float32")
|
| 100 |
+
norms = np.linalg.norm(arr, axis=1, keepdims=True)
|
| 101 |
+
norms[norms == 0] = 1.0
|
| 102 |
+
arr = arr / norms
|
| 103 |
+
return arr
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
@st.cache_data
|
| 107 |
+
def carica_corpus() -> List[Dict[str, str]]:
|
| 108 |
+
path = Path("demo_corpus.json")
|
| 109 |
+
data = json.loads(path.read_text(encoding="utf-8"))
|
| 110 |
+
for r in data:
|
| 111 |
+
r["text"] = normalizza_testo(r.get("text", ""))
|
| 112 |
+
return data
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
@st.cache_resource
|
| 116 |
+
def prepara_engine():
|
| 117 |
+
model, backend = inizializza_embedder()
|
| 118 |
+
records = carica_corpus()
|
| 119 |
+
texts = [r["text"] for r in records]
|
| 120 |
+
mat = vectorizza(model, texts)
|
| 121 |
+
return model, backend, records, mat
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def cerca(query: str, model, records, mat: np.ndarray, top_k: int = 5):
|
| 125 |
+
qv = vectorizza(model, [query])[0]
|
| 126 |
+
sims = mat @ qv
|
| 127 |
+
qtok = set(tokenizza(query))
|
| 128 |
+
out = []
|
| 129 |
+
for i, s in enumerate(sims):
|
| 130 |
+
rec = records[i]
|
| 131 |
+
ttok = set(tokenizza(rec["text"]))
|
| 132 |
+
overlap = len(qtok.intersection(ttok)) if qtok else 0
|
| 133 |
+
lex = (overlap / max(1, len(qtok))) if qtok else 0.0
|
| 134 |
+
score = 0.6 * float(s) + 0.4 * float(lex)
|
| 135 |
+
out.append(
|
| 136 |
+
{
|
| 137 |
+
"score": score,
|
| 138 |
+
"sim": float(s),
|
| 139 |
+
"lex": float(lex),
|
| 140 |
+
"domain": rec.get("domain", "generale"),
|
| 141 |
+
"source": rec.get("source", "showcase"),
|
| 142 |
+
"text": rec.get("text", ""),
|
| 143 |
+
}
|
| 144 |
+
)
|
| 145 |
+
out.sort(key=lambda x: x["score"], reverse=True)
|
| 146 |
+
return out[:top_k]
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
st.set_page_config(page_title="AIO Showcase", page_icon=":books:", layout="centered")
|
| 150 |
+
st.title("AIO System Core - Public Showcase")
|
| 151 |
+
st.caption("Demo pubblica controllata. Core proprietario e corpus completo restano privati.")
|
| 152 |
+
|
| 153 |
+
model, backend, records, mat = prepara_engine()
|
| 154 |
+
st.caption(f"Backend: {backend}")
|
| 155 |
+
st.caption(f"Records demo: {len(records)}")
|
| 156 |
+
|
| 157 |
+
query = st.text_input("Inserisci una domanda", value="Parlami del Mediterraneo e della geopolitica energetica")
|
| 158 |
+
top_k = st.slider("Top K", min_value=3, max_value=10, value=5, step=1)
|
| 159 |
+
|
| 160 |
+
if st.button("Esegui ricerca"):
|
| 161 |
+
risultati = cerca(query, model, records, mat, top_k=top_k)
|
| 162 |
+
st.subheader("Risultati")
|
| 163 |
+
for i, r in enumerate(risultati, start=1):
|
| 164 |
+
st.markdown(
|
| 165 |
+
f"**{i}. [{r['domain']}]** score={r['score']:.3f} sim={r['sim']:.3f} lex={r['lex']:.3f}"
|
| 166 |
+
)
|
| 167 |
+
st.caption(f"source: {r['source']}")
|
| 168 |
+
st.write(r["text"])
|
| 169 |
+
|
| 170 |
+
st.markdown("---")
|
| 171 |
+
st.markdown("**Licenza Showcase:** uso e studio liberi, uso commerciale solo su autorizzazione scritta.")
|
| 172 |
+
st.markdown("Contatto: `info@rthitalia.com`")
|
demo_corpus.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"domain": "biologia",
|
| 4 |
+
"source": "showcase:bio_01",
|
| 5 |
+
"text": "La biologia dei sistemi studia reti di regolazione, feedback e adattamento in organismi complessi."
|
| 6 |
+
},
|
| 7 |
+
{
|
| 8 |
+
"domain": "biologia",
|
| 9 |
+
"source": "showcase:bio_02",
|
| 10 |
+
"text": "L'immunita innata e adattativa cooperano per identificare minacce e mantenere omeostasi."
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"domain": "finanza",
|
| 14 |
+
"source": "showcase:fin_01",
|
| 15 |
+
"text": "La gestione del rischio richiede limiti di esposizione, stress test e controllo della varianza."
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"domain": "finanza",
|
| 19 |
+
"source": "showcase:fin_02",
|
| 20 |
+
"text": "Inflazione, tassi e liquidita influenzano valutazioni, costo del capitale e investimenti."
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"domain": "fisica",
|
| 24 |
+
"source": "showcase:phy_01",
|
| 25 |
+
"text": "La termodinamica descrive trasformazioni energetiche, entropia e vincoli di irreversibilita."
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"domain": "fisica",
|
| 29 |
+
"source": "showcase:phy_02",
|
| 30 |
+
"text": "In meccanica quantistica, lo stato del sistema evolve secondo dinamiche probabilistiche."
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"domain": "matematica",
|
| 34 |
+
"source": "showcase:mat_01",
|
| 35 |
+
"text": "Probabilita e statistica permettono inferenza su dati incompleti e decisioni sotto incertezza."
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"domain": "matematica",
|
| 39 |
+
"source": "showcase:mat_02",
|
| 40 |
+
"text": "L'algebra lineare fornisce strutture per ottimizzazione, segnali e modelli numerici."
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"domain": "tecnologia",
|
| 44 |
+
"source": "showcase:tec_01",
|
| 45 |
+
"text": "Un sistema robusto combina modularita, osservabilita e automazione dei controlli di qualita."
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"domain": "tecnologia",
|
| 49 |
+
"source": "showcase:tec_02",
|
| 50 |
+
"text": "L'architettura software orientata a componenti riduce accoppiamento e facilita evoluzione."
|
| 51 |
+
},
|
| 52 |
+
{
|
| 53 |
+
"domain": "filosofia_psicologia",
|
| 54 |
+
"source": "showcase:phi_01",
|
| 55 |
+
"text": "La psicologia cognitiva analizza bias, attenzione e processi decisionali in ambienti complessi."
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"domain": "filosofia_psicologia",
|
| 59 |
+
"source": "showcase:phi_02",
|
| 60 |
+
"text": "L'epistemologia valuta affidabilita delle fonti e criteri di validazione della conoscenza."
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"domain": "storia_politica_diritto",
|
| 64 |
+
"source": "showcase:law_01",
|
| 65 |
+
"text": "Lo stato di diritto richiede norme applicabili, trasparenza istituzionale e responsabilita."
|
| 66 |
+
},
|
| 67 |
+
{
|
| 68 |
+
"domain": "storia_politica_diritto",
|
| 69 |
+
"source": "showcase:law_02",
|
| 70 |
+
"text": "La geopolitica del Mediterraneo dipende da rotte energetiche, sicurezza marittima e diplomazia."
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"domain": "terra_clima",
|
| 74 |
+
"source": "showcase:cli_01",
|
| 75 |
+
"text": "Il cambiamento climatico altera regimi idrologici, eventi estremi e vulnerabilita territoriale."
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"domain": "terra_clima",
|
| 79 |
+
"source": "showcase:cli_02",
|
| 80 |
+
"text": "L'oceanografia integra dinamica dei fluidi, chimica marina e cicli biogeochimici."
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"domain": "chimica",
|
| 84 |
+
"source": "showcase:chem_01",
|
| 85 |
+
"text": "La cinetica chimica studia velocita di reazione e dipendenza da temperatura e concentrazione."
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"domain": "chimica",
|
| 89 |
+
"source": "showcase:chem_02",
|
| 90 |
+
"text": "Catalisi ed elettrochimica sono centrali in accumulo energetico e processi industriali."
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"domain": "mediterraneo",
|
| 94 |
+
"source": "showcase:med_01",
|
| 95 |
+
"text": "Il Mediterraneo connette Europa, Africa e Asia attraverso corridoi logistici e culturali."
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"domain": "mediterraneo",
|
| 99 |
+
"source": "showcase:med_02",
|
| 100 |
+
"text": "Canale di Suez e Stretto di Gibilterra sono nodi strategici della mobilita globale."
|
| 101 |
+
},
|
| 102 |
+
{
|
| 103 |
+
"domain": "cucina",
|
| 104 |
+
"source": "showcase:food_01",
|
| 105 |
+
"text": "Le tecniche di cottura modificano struttura molecolare, sapore e digeribilita degli alimenti."
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"domain": "cucina",
|
| 109 |
+
"source": "showcase:food_02",
|
| 110 |
+
"text": "La dieta mediterranea integra nutrizione, stagionalita e sostenibilita culturale."
|
| 111 |
+
}
|
| 112 |
+
]
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit>=1.42
|
| 2 |
+
numpy>=1.26
|
| 3 |
+
sentence-transformers>=3.0
|