Update README.md
Browse files
README.md
CHANGED
@@ -75,7 +75,7 @@ unmasker("одежда женское [MASK] для_праздника")
|
|
75 |
|
76 |
```
|
77 |
|
78 |
-
For transformers.js, it turned out that the ONNX version of the model was required.
|
79 |
|
80 |
|
81 |
```python
|
@@ -87,3 +87,56 @@ tokenizer = AutoTokenizer.from_pretrained("fkrasnov2/COLD2")
|
|
87 |
model = ORTModelForMaskedLM.from_pretrained("fkrasnov2/COLD2", file_name='model.onnx')
|
88 |
|
89 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
```
|
77 |
|
78 |
+
## For transformers.js, it turned out that the ONNX version of the model was required.
|
79 |
|
80 |
|
81 |
```python
|
|
|
87 |
model = ORTModelForMaskedLM.from_pretrained("fkrasnov2/COLD2", file_name='model.onnx')
|
88 |
|
89 |
```
|
90 |
+
## You can also run and use the model straight from your browser.
|
91 |
+
|
92 |
+
```
|
93 |
+
index.html
|
94 |
+
```
|
95 |
+
|
96 |
+
```html
|
97 |
+
<!DOCTYPE html>
|
98 |
+
<html lang="ru">
|
99 |
+
<head>
|
100 |
+
<meta charset="UTF-8">
|
101 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
102 |
+
<title>Mask fill</title>
|
103 |
+
<link rel="stylesheet" href="styles.css">
|
104 |
+
<script src="main.js" type="module" defer></script>
|
105 |
+
</head>
|
106 |
+
<body>
|
107 |
+
<div class="container">
|
108 |
+
<textarea id="long-text-input" placeholder="Enter search query with [MASK]"></textarea>
|
109 |
+
<button id="generate-button">
|
110 |
+
Заполнить маску
|
111 |
+
</button>
|
112 |
+
<div id="output-div"></div>
|
113 |
+
</div>
|
114 |
+
</body>
|
115 |
+
</html>
|
116 |
+
```
|
117 |
+
|
118 |
+
|
119 |
+
```
|
120 |
+
main.js
|
121 |
+
```
|
122 |
+
|
123 |
+
```javascript
|
124 |
+
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]';
|
125 |
+
|
126 |
+
const longTextInput = document.getElementById('long-text-input');
|
127 |
+
const output = document.getElementById('output-div');
|
128 |
+
|
129 |
+
const pipe = await pipeline(
|
130 |
+
'fill-mask', // task
|
131 |
+
'fkrasnov2/COLD2' // model
|
132 |
+
);
|
133 |
+
|
134 |
+
generateButton.addEventListener('click', async () => {
|
135 |
+
|
136 |
+
const input = longTextInput.value;
|
137 |
+
const result = await pipe(input);
|
138 |
+
|
139 |
+
output.innerHTML = result[0].sequence;
|
140 |
+
output.style.display = 'block';
|
141 |
+
});
|
142 |
+
```
|