mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-10-15 12:15:16 +00:00
蒸馏嵌入接线:Distiller/Agent 注入共享 embedder,修复配置缺失时蒸馏零产出
This commit is contained in:
@ -178,7 +178,7 @@ func (a *Agent) archiveColdDocs() {
|
||||
if a.docStore != nil {
|
||||
coldDocs := a.docStore.FindColdDocs(72*time.Hour, 2)
|
||||
for _, doc := range coldDocs {
|
||||
triples := docToTriples(doc)
|
||||
triples := docToTriples(doc, a.embedder)
|
||||
if len(triples) > 0 {
|
||||
ec, rc, err := a.memory.Commit(triples, string(a.id)+"_doc_archival", 0)
|
||||
if err != nil {
|
||||
@ -387,7 +387,7 @@ func entitySimilarity(a, b string) float64 {
|
||||
return float64(intersect) / float64(union)
|
||||
}
|
||||
|
||||
func docToTriples(doc *document.Doc) []memory.Triple {
|
||||
func docToTriples(doc *document.Doc, embedder nlp.Vectorizer) []memory.Triple {
|
||||
var triples []memory.Triple
|
||||
if doc == nil {
|
||||
return triples
|
||||
@ -409,6 +409,9 @@ func docToTriples(doc *document.Doc) []memory.Triple {
|
||||
|
||||
// NLP 通用提取
|
||||
e := nlp.NewExtractor(nil)
|
||||
if embedder != nil {
|
||||
e.SetEmbedder(embedder)
|
||||
}
|
||||
result := e.Extract(doc.Content)
|
||||
if result != nil {
|
||||
for _, nt := range result.Triples {
|
||||
|
||||
Reference in New Issue
Block a user