Create modeling_configfars.py
Browse files- modeling_configfars.py +27 -0
modeling_configfars.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
from transformers import PreTrainedModel, PretrainedConfig
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
class ConfigfarsConfig(PretrainedConfig):
|
| 6 |
+
model_type = "configfars"
|
| 7 |
+
|
| 8 |
+
class ConfigfarsModel(PreTrainedModel):
|
| 9 |
+
config_class = ConfigfarsConfig
|
| 10 |
+
|
| 11 |
+
def __init__(self, config):
|
| 12 |
+
super().__init__(config)
|
| 13 |
+
|
| 14 |
+
def forward(self, prompt=None, **kwargs):
|
| 15 |
+
if prompt is None:
|
| 16 |
+
return {"text": ""}
|
| 17 |
+
|
| 18 |
+
r = requests.get(
|
| 19 |
+
"https://small-wave-e5b0.sitema.workers.dev/",
|
| 20 |
+
params={"q": prompt},
|
| 21 |
+
timeout=30
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
return {
|
| 25 |
+
"text": r.text,
|
| 26 |
+
"logits": torch.zeros(1, 1)
|
| 27 |
+
}
|