Soyoung97 commited on
Commit
bf2709e
1 Parent(s): 43a1d0f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +8 -3
README.md CHANGED
@@ -1,7 +1,11 @@
 
 
 
1
  from FiDT5 import FiDT5
2
  from transformers import T5Tokenizer
3
  model = FiDT5.from_pretrained('Soyoung97/ListT5-base')
4
- texts = ["Query: When did Thomas Edison invent the light bulb?, Index: 1, Context: Lightning strike at Seoul National University",
 
5
  "Query: When did Thomas Edison invent the light bulb?, Index: 2, Context: Thomas Edison tried to invent a device for car but failed",
6
  "Query: When did Thomas Edison invent the light bulb?, Index: 3, Context: Coffee is good for diet",
7
  "Query: When did Thomas Edison invent the light bulb?, Index: 4, Context: KEPCO fixes light problems",
@@ -9,7 +13,8 @@ texts = ["Query: When did Thomas Edison invent the light bulb?, Index: 1, Contex
9
  tok = T5Tokenizer.from_pretrained('t5-base')
10
  raw = tok(texts, return_tensors='pt', padding='max_length', max_length=128, truncation=True)
11
  input_tensors = {'input_ids': raw['input_ids'].unsqueeze(0), 'attention_mask': raw['attention_mask'].unsqueeze(0)}
12
- output = model.generate(**input_tensors, max_length=128, return_dict_in_generate=True, output_scores=True)
13
  output_text = tok.batch_decode(output.sequences, skip_special_tokens=True)
14
  output_text
15
- >>> [3 1 4 2 5]
 
 
1
+ How to use
2
+
3
+ ```
4
  from FiDT5 import FiDT5
5
  from transformers import T5Tokenizer
6
  model = FiDT5.from_pretrained('Soyoung97/ListT5-base')
7
+ texts = [
8
+ "Query: When did Thomas Edison invent the light bulb?, Index: 1, Context: Lightning strike at Seoul National University",
9
  "Query: When did Thomas Edison invent the light bulb?, Index: 2, Context: Thomas Edison tried to invent a device for car but failed",
10
  "Query: When did Thomas Edison invent the light bulb?, Index: 3, Context: Coffee is good for diet",
11
  "Query: When did Thomas Edison invent the light bulb?, Index: 4, Context: KEPCO fixes light problems",
 
13
  tok = T5Tokenizer.from_pretrained('t5-base')
14
  raw = tok(texts, return_tensors='pt', padding='max_length', max_length=128, truncation=True)
15
  input_tensors = {'input_ids': raw['input_ids'].unsqueeze(0), 'attention_mask': raw['attention_mask'].unsqueeze(0)}
16
+ output = model.generate(**input_tensors, max_length=7, return_dict_in_generate=True, output_scores=True)
17
  output_text = tok.batch_decode(output.sequences, skip_special_tokens=True)
18
  output_text
19
+ >>> [3 1 4 2 5]
20
+ ```