pszemraj commited on
Commit
4d4158f
1 Parent(s): 3e8f837

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +14 -0
README.md CHANGED
@@ -15,6 +15,20 @@ The encoder model extracted from [flan-ul2](https://huggingface.co/google/flan-u
15
 
16
  ## basic usage
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  > note: this is 'one way' to use the encoder, not 'the only way'. suggestions and ideas welcome.
19
 
20
  Below is an example and a set of functions to compute the cosine similarity between the embeddings of different texts with this model
 
15
 
16
  ## basic usage
17
 
18
+ ```python
19
+ from transformers import AutoTokenizer, AutoModelForTextEncoding
20
+
21
+ tokenizer = AutoTokenizer.from_pretrained("pszemraj/flan-ul2-text-encoder")
22
+ model = AutoModelForTextEncoding.from_pretrained("pszemraj/flan-ul2-text-encoder")
23
+
24
+ inputs = tokenizer("Hello, my dog loves memes", return_tensors="pt")
25
+ outputs = model(**inputs)
26
+
27
+ last_hidden_states = outputs.last_hidden_state
28
+ ```
29
+
30
+ ## usage: semantic similarity
31
+
32
  > note: this is 'one way' to use the encoder, not 'the only way'. suggestions and ideas welcome.
33
 
34
  Below is an example and a set of functions to compute the cosine similarity between the embeddings of different texts with this model