Instructions to use uzabase/UBKE-LUKE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use uzabase/UBKE-LUKE with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="uzabase/UBKE-LUKE", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("uzabase/UBKE-LUKE", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -67,12 +67,12 @@ Entity Recognition Results:
|
|
| 67 |
- 各次元のlogit値は,入力文章における各entityの関連度を表現しています.
|
| 68 |
|
| 69 |
### 4. entity_logits(entityの埋め込み表現)
|
| 70 |
-
- entityの一覧は,tokenizerがentity_vocabに辞書形式で持
|
| 71 |
```
|
| 72 |
tokenizer.entity_vocab # => {"": 0, ... ,"AGC": 48, ....
|
| 73 |
tokenizer.entity_vocab["味の素"] # => 8469(味の素のentity_id)
|
| 74 |
```
|
| 75 |
-
- entity_spans及びentitties引数をtokenizerに渡し,tokenをencodeすることで,entityの埋め込み表現を得
|
| 76 |
```
|
| 77 |
model.eval()
|
| 78 |
tokens = tokenizer("味の素", entities=["味の素"], entity_spans=[(0, 3)], truncation=True, max_length=512, return_tensors="pt")
|
|
@@ -81,7 +81,7 @@ with torch.no_grad():
|
|
| 81 |
outputs = model(**tokens)
|
| 82 |
outputs.entity_logits.shape # 味の素のentity_vector
|
| 83 |
```
|
| 84 |
-
- entityの埋め込み表現の内積(やコサイン類似度)を計算することで,entity同士の類似度を計算可能
|
| 85 |
```
|
| 86 |
def encode(entity_text):
|
| 87 |
model.eval()
|
|
|
|
| 67 |
- 各次元のlogit値は,入力文章における各entityの関連度を表現しています.
|
| 68 |
|
| 69 |
### 4. entity_logits(entityの埋め込み表現)
|
| 70 |
+
- entityの一覧は,tokenizerがentity_vocabに辞書形式で持ちます.
|
| 71 |
```
|
| 72 |
tokenizer.entity_vocab # => {"": 0, ... ,"AGC": 48, ....
|
| 73 |
tokenizer.entity_vocab["味の素"] # => 8469(味の素のentity_id)
|
| 74 |
```
|
| 75 |
+
- entity_spans及びentitties引数をtokenizerに渡し,tokenをencodeすることで,entityの埋め込み表現を得ます.
|
| 76 |
```
|
| 77 |
model.eval()
|
| 78 |
tokens = tokenizer("味の素", entities=["味の素"], entity_spans=[(0, 3)], truncation=True, max_length=512, return_tensors="pt")
|
|
|
|
| 81 |
outputs = model(**tokens)
|
| 82 |
outputs.entity_logits.shape # 味の素のentity_vector
|
| 83 |
```
|
| 84 |
+
- entityの埋め込み表現の内積(やコサイン類似度)を計算することで,entity同士の類似度を計算可能です.
|
| 85 |
```
|
| 86 |
def encode(entity_text):
|
| 87 |
model.eval()
|