ConceptMatcher

class linear_relational.ConceptMatcher(model, tokenizer, concepts, layer_matcher=None, map_activations_fn=None)[source]

Match concepts against subject activations in a model

concepts
layer_matcher
layer_name_to_num
map_activations_fn
model
query(query, subject)[source]
query_bulk(queries, batch_size=4, verbose=False)[source]
tokenizer
class linear_relational.ConceptMatchQuery(text: str, subject: str | int | Callable[[str, list[int]], int])[source]
subject
text
class linear_relational.QueryResult(concept_results: dict[str, linear_relational.ConceptMatcher.ConceptMatchResult])[source]
property best_match
concept_results
class linear_relational.ConceptMatchResult(concept: str, score: float)[source]
concept
score