Update README.md
Browse files
README.md
CHANGED
@@ -74,15 +74,15 @@ This model can be easily loaded using the **Hugging Face Transformers** library.
|
|
74 |
🔗 **[Colab Demo (Replace with "CodeModernBERT-Owl")](https://github.com/Shun0212/CodeBERTPretrained/blob/main/UseMyCodeMorph_ModernBERT.ipynb)**
|
75 |
|
76 |
### **モデルのロード / Load the Model**
|
77 |
-
python
|
78 |
from transformers import AutoModelForMaskedLM, AutoTokenizer
|
79 |
|
80 |
tokenizer = AutoTokenizer.from_pretrained("Shuu12121/CodeModernBERT-Owl")
|
81 |
model = AutoModelForMaskedLM.from_pretrained("Shuu12121/CodeModernBERT-Owl")
|
82 |
-
|
83 |
|
84 |
### **コード埋め込みの取得 / Get Code Embeddings**
|
85 |
-
python
|
86 |
import torch
|
87 |
|
88 |
def get_embedding(text, model, tokenizer, device="cuda"):
|
@@ -96,6 +96,7 @@ def get_embedding(text, model, tokenizer, device="cuda"):
|
|
96 |
|
97 |
embedding = get_embedding("def my_function(): pass", model, tokenizer)
|
98 |
print(embedding.shape)
|
|
|
99 |
|
100 |
|
101 |
---
|
|
|
74 |
🔗 **[Colab Demo (Replace with "CodeModernBERT-Owl")](https://github.com/Shun0212/CodeBERTPretrained/blob/main/UseMyCodeMorph_ModernBERT.ipynb)**
|
75 |
|
76 |
### **モデルのロード / Load the Model**
|
77 |
+
```python
|
78 |
from transformers import AutoModelForMaskedLM, AutoTokenizer
|
79 |
|
80 |
tokenizer = AutoTokenizer.from_pretrained("Shuu12121/CodeModernBERT-Owl")
|
81 |
model = AutoModelForMaskedLM.from_pretrained("Shuu12121/CodeModernBERT-Owl")
|
82 |
+
```
|
83 |
|
84 |
### **コード埋め込みの取得 / Get Code Embeddings**
|
85 |
+
```python
|
86 |
import torch
|
87 |
|
88 |
def get_embedding(text, model, tokenizer, device="cuda"):
|
|
|
96 |
|
97 |
embedding = get_embedding("def my_function(): pass", model, tokenizer)
|
98 |
print(embedding.shape)
|
99 |
+
```
|
100 |
|
101 |
|
102 |
---
|