Skip to content

Commit

Permalink
Merge pull request #99 from BiEchi/patch-1
Browse files Browse the repository at this point in the history
Update lm.py to suit OPT-like models
  • Loading branch information
jalammar committed Aug 10, 2023
2 parents 78abb38 + aab5b7d commit e292773
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ecco/lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ def __init__(self,
self.model_type = self.model_config['type']
embeddings_layer_name = self.model_config['embedding']
embed_retriever = attrgetter(embeddings_layer_name)
self.model_embeddings = embed_retriever(self.model)
if type(embed_retriever(self.model)) == torch.nn.Embedding:
self.model_embeddings = embed_retriever(self.model).weight
else:
self.model_embeddings = embed_retriever(self.model)
self.collect_activations_layer_name_sig = self.model_config['activations'][0]
except KeyError:
raise ValueError(
Expand Down

0 comments on commit e292773

Please sign in to comment.