interpretable embeddings
1.0.0
通過詢問LLMS問題,QA-EMB論文的代碼來製作可解釋的嵌入。
Qa-Embs通過向預培訓的自回歸LLM提出一系列不是問題來構建可解釋的嵌入。 
如果您只想在自己的應用程序中使用QA-EMB,則最簡單的方法是通過Imodelsx軟件包。要安裝,只需運行pip install imodelsx即可。
然後,您可以通過提出有關域的問題來生成自己的可解釋的嵌入:
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 - - - - - - - -在論文中重現fMRI實驗所需的數據集的說明。
python experiments/00_load_dataset.pydata元neuro1.config.root_dir設置為要存儲數據的位置{root_dir}/ds003020/derivative/pycortex-db/ flatmapem_data目錄,然後將其內容移至{root_dir}/em_dataneuro1.data.response_utils功能load_response{root_dir}/ds003020/derivative/preprocessed_data/{subject} wheretheressmoke.h5響應,它們存儲在每個故事的H5文件中neuro1.features.stim_utils功能load_story_wordseqs{root_dir}/ds003020/derivative/TextGrids", where each story has a TextGrid file, eg wheretheressmoke.textgrid`{root_dir}/ds003020/derivative/respdict.json獲取每個故事的長度在此處安裝代碼作為完整開發的包裝的說明。
pip install -e .在本地安裝neuro1軟件包python 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 }
}