Gleb Vinarskis
commited on
Commit
·
fe41f06
1
Parent(s):
e43531a
tedst
Browse files- __init__.py +2 -22
- config.json +3 -3
- modeling_custom.py +18 -0
__init__.py
CHANGED
@@ -1,24 +1,4 @@
|
|
|
|
1 |
from .custom_pipeline import Pipeline_One
|
2 |
-
from transformers import PretrainedConfig
|
3 |
|
4 |
-
|
5 |
-
model_type = "custom"
|
6 |
-
|
7 |
-
def __init__(
|
8 |
-
self,
|
9 |
-
num_labels=3,
|
10 |
-
id2label=None,
|
11 |
-
label2id=None,
|
12 |
-
**kwargs
|
13 |
-
):
|
14 |
-
if id2label is None:
|
15 |
-
id2label = {0: "English", 1: "German", 2: "French"}
|
16 |
-
if label2id is None:
|
17 |
-
label2id = {"English": 0, "German": 1, "French": 2}
|
18 |
-
|
19 |
-
super().__init__(
|
20 |
-
num_labels=num_labels,
|
21 |
-
id2label=id2label,
|
22 |
-
label2id=label2id,
|
23 |
-
**kwargs
|
24 |
-
)
|
|
|
1 |
+
from .modeling_custom import CustomConfig, CustomModel
|
2 |
from .custom_pipeline import Pipeline_One
|
|
|
3 |
|
4 |
+
__all__ = ["CustomConfig", "CustomModel", "Pipeline_One"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
{
|
2 |
"_name_or_path": "Maslionok/pipeline1",
|
3 |
"architectures": [
|
4 |
-
"
|
5 |
],
|
6 |
-
"model_type": "
|
7 |
"num_labels": 3,
|
8 |
"id2label": {
|
9 |
"0": "English",
|
@@ -17,7 +17,7 @@
|
|
17 |
},
|
18 |
"custom_pipelines": {
|
19 |
"language-detection": {
|
20 |
-
"impl": "Pipeline_One",
|
21 |
"pt": [],
|
22 |
"tf": []
|
23 |
}
|
|
|
1 |
{
|
2 |
"_name_or_path": "Maslionok/pipeline1",
|
3 |
"architectures": [
|
4 |
+
"CustomModel"
|
5 |
],
|
6 |
+
"model_type": "langident",
|
7 |
"num_labels": 3,
|
8 |
"id2label": {
|
9 |
"0": "English",
|
|
|
17 |
},
|
18 |
"custom_pipelines": {
|
19 |
"language-detection": {
|
20 |
+
"impl": "custom_pipeline.Pipeline_One",
|
21 |
"pt": [],
|
22 |
"tf": []
|
23 |
}
|
modeling_custom.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import PreTrainedModel
|
2 |
+
from transformers.configuration_utils import PretrainedConfig
|
3 |
+
|
4 |
+
class CustomConfig(PretrainedConfig):
|
5 |
+
model_type = "langident" # Changed from "custom" to a specific type
|
6 |
+
|
7 |
+
def __init__(self, **kwargs):
|
8 |
+
super().__init__(**kwargs)
|
9 |
+
|
10 |
+
class CustomModel(PreTrainedModel):
|
11 |
+
config_class = CustomConfig
|
12 |
+
|
13 |
+
def __init__(self, config):
|
14 |
+
super().__init__(config)
|
15 |
+
|
16 |
+
def forward(self, **kwargs):
|
17 |
+
# Implement your forward pass
|
18 |
+
pass
|