interpretable embeddings
1.0.0
Basteln interpretierbare Einbettungen durch Stellen von LLMs Fragen, Code für das QA-EMB-Papier.
QA-EMBs baut eine interpretierbare Einbettung auf, indem sie eine Reihe von Ja-No-Fragen an ein vorgebildetes autoregressives LLM stellen. 
Wenn Sie nur QA-EMB in Ihrer eigenen Anwendung verwenden möchten, ist der einfachste Weg über das Imodelsx-Paket. Um zu installieren, führen Sie einfach pip install imodelsx .
Dann können Sie Ihre eigenen interpretierbaren Einbettungen erzeugen, indem Sie Fragen für Ihre Domain stellen:
from imodelsx import QAEmb
import pandas as pd
questions = [
'Is the input related to food preparation?' ,
'Does the input mention laughter?' ,
'Is there an expression of surprise?' ,
'Is there a depiction of a routine or habit?' ,
'Does the sentence contain stuttering?' ,
'Does the input contain a first-person pronoun?' ,
]
examples = [
'i sliced some cucumbers and then moved on to what was next' ,
'the kids were giggling about the silly things they did' ,
'and i was like whoa that was unexpected' ,
'walked down the path like i always did' ,
'um no um then it was all clear' ,
'i was walking to school and then i saw a cat' ,
]
checkpoint = 'meta-llama/Meta-Llama-3-8B-Instruct'
embedder = QAEmb (
questions = questions , checkpoint = checkpoint , use_cache = False )
embeddings = embedder ( examples )
df = pd . DataFrame ( embeddings . astype ( int ), columns = [
q . split ()[ - 1 ] for q in questions ])
df . index = examples
df . columns . name = 'Question (abbreviated)'
display ( df . style . background_gradient ( axis = None ))
- - - - - - - - DISPLAYS ANSWER FOR EACH QUESTION IN EMBEDDING - - - - - - - -Anweisungen zur Installation der Datensätze zur Reproduktion der fMRI -Experimente im Papier.
python experiments/00_load_dataset.py herunterdata -Dir, unter wo immer Sie es ausführen, und verwendet Datalad, um die vorverarbeiteten Daten sowie Funktionsräume herunterzuladen, die für die Anpassung semantischer Codierungsmodelle benötigt werdenneuro1.config.root_dir so, dass Sie die Daten speichern möchten{root_dir}/ds003020/derivative/pycortex-db/ festgelegt werden{root_dir}/em_data Eng1000 em_dataneuro1.data.response_utils Funktion load_response{root_dir}/ds003020/derivative/preprocessed_data/{subject} , heiler werden in einer H5 -Datei für jede Geschichte gespeichert, z wheretheressmoke.h5neuro1.features.stim_utils Funktion load_story_wordseqs{root_dir}/ds003020/derivative/TextGrids", where each story has a TextGrid file, eg .{root_dir}/ds003020/derivative/respdict.json um die Länge jeder Geschichte zu erhaltenAnweisungen zur Installation des Codes hier als Paket für die vollständige Entwicklung.
pip install -e . Um das neuro1 -Paket lokal zu installierenpython 01_fit_encoding.py --subject UTS03 --feature eng1000 @ misc { benara2024crafting ,
title = { Crafting Interpretable Embeddings by Asking LLMs Questions },
author = { Vinamra Benara and Chandan Singh and John X. Morris and Richard Antonello and Ion Stoica and Alexander G. Huth and Jianfeng Gao },
year = { 2024 },
eprint = { 2405.16714 },
archivePrefix = { arXiv },
primaryClass = { cs.CL }
}