philipp-zettl commited on
Commit
8f523c5
1 Parent(s): a29b1fa

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +12 -76
README.md CHANGED
@@ -10,82 +10,6 @@ metrics:
10
  - f1
11
  - recall
12
  model_name: GGU-CLF
13
- description: '
14
-
15
- This is a simple classification model trained on a custom dataset.
16
-
17
- It is used to classify user text into the following classes:
18
-
19
- - 0: Greeting
20
-
21
- - 1: Gratitude
22
-
23
- - 2: Unknown
24
-
25
-
26
- **Note**: To use this model please remember the following things
27
-
28
- 1. The model is based on BAAI/bge-m3; You need to obtain the weights of this model
29
- before you can use the classifier
30
-
31
- 2. To load the model weights you need to pass the base model and tokenizer to the
32
- classifiers constructor
33
-
34
-
35
-
36
- '
37
- direct_use: Use this model to classify messages from natural language chats.
38
- out_of_scope_use: '
39
-
40
- The model was not trained on multi-sentence samples. **You should avoid those.**
41
-
42
-
43
- Oficially tested and supported languages are **english and german** any other language
44
- is considered out of scope.
45
-
46
- '
47
- training_data: '
48
-
49
- This model was trained using the [philipp-zettl/GGU-xx](https://huggingface.co/dataset/philipp-zettl/GGU-xx)
50
- dataset.
51
-
52
-
53
- You can find it''s performance metrics under [Evaluation Results](#evaluation-results).
54
-
55
- '
56
- preprocessing: "\nThe following code was used to create the data set as well as split\
57
- \ the data set into training and validation sets.\n\n```python\nfrom datasets import\
58
- \ load_dataset\n\nclass Dataset:\n def __init__(self, dataset, target_names=None):\n\
59
- \ self.data = list(map(lambda x: x[0], dataset))\n self.target = list(map(lambda\
60
- \ x: x[1], dataset))\n self.target_names = target_names\n\n\nds = load_dataset('philipp-zettl/GGU-xx')\n\
61
- data = Dataset([[e['sample'], e['label']] for e in ds['train']], ['greeting', 'gratitude',\
62
- \ 'unknown'])\nX_train, X_test, y_train, y_test = train_test_split(data.data, data.target,\
63
- \ test_size=0.2, random_state=42)\n```\n"
64
- get_started_code: "\n```python\nfrom transformers import AutoModel, AutoTokenizer\n\
65
- \nbase = AutoModel.from_pretrained('BAAI/bge-m3')\ntokenizer = AutoTokenizer.from_pretrained('BAAI/bge-m3')\n\
66
- \nmodel = EmbClf.from_pretrained(\"philipp-zettl/GGU-xx\", base_model=base.to(torch.float16),\
67
- \ tokenizer=tokenizer).to('cuda').to(torch.float16)\n\nmodel([\n 'Hi was geht?',\n\
68
- \ 'Greetings, friendo!',\n 'I highly appreciate this gesture.',\n 'Merci\
69
- \ beaucoup, nous espérons que tout se passera bien'\n]).argmax(dim=1)\n```\n"
70
- model_examination: "\nYou can find the initial implementation of the classification\
71
- \ model here:\n\n```python\nfrom huggingface_hub import PyTorchModelHubMixin\nimport\
72
- \ torch\nimport torch.nn as nn\n\nclass EmbClf(nn.Module, PyTorchModelHubMixin):\n\
73
- \ def __init__(self, base_model, tokenizer, num_classes, dropout=0.0, l2_reg=0.01,\
74
- \ device=None):\n super().__init__()\n\n self.tokenizer = tokenizer\n\
75
- \ self.base = base_model\n self.fc = nn.Linear(base.config.hidden_size,\
76
- \ num_classes)\n self.do = nn.Dropout(dropout)\n self.device = device\n\
77
- \ self.l2_reg = l2_reg\n\n def forward(self, X):\n encoding = self.tokenizer(X,\
78
- \ return_tensors='pt', padding=True, truncation=True).to(self.device)\n input_ids\
79
- \ = encoding['input_ids']\n attention_mask = encoding['attention_mask']\n\
80
- \ emb = self.base(\n input_ids,\n attention_mask=attention_mask,\n\
81
- \ return_dict=True,\n output_hidden_states=True\n ).last_hidden_state[:,\
82
- \ 0, :]\n return self.fc(self.do(emb))\n\n def train(self, set_val=True):\n\
83
- \ self.base.train(False)\n for param in self.base.parameters():\n\
84
- \ param.requires_grad = False\n for param in self.fc.parameters():\n\
85
- \ param.requires_grad = set_val\n\n def get_l2_loss(self):\n \
86
- \ l2_loss = torch.tensor(0.).to('cuda')\n for param in self.parameters():\n\
87
- \ if param.requires_grad:\n l2_loss += torch.norm(param,\
88
- \ 2)\n return self.l2_reg * l2_loss\n```\n"
89
  pipeline_tag: text-classification
90
  widget:
91
  - name: test1
@@ -105,6 +29,18 @@ widget:
105
  <!-- Provide a longer summary of what this model is. -->
106
 
107
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  - **Developed by:** [philipp-zettl](https://huggingface.co/philipp-zettl/)
110
  - **Funded by [optional]:** [More Information Needed]
 
10
  - f1
11
  - recall
12
  model_name: GGU-CLF
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  pipeline_tag: text-classification
14
  widget:
15
  - name: test1
 
29
  <!-- Provide a longer summary of what this model is. -->
30
 
31
 
32
+ This is a simple classification model trained on a custom dataset.
33
+ It is used to classify user text into the following classes:
34
+ - 0: Greeting
35
+ - 1: Gratitude
36
+ - 2: Unknown
37
+
38
+ **Note**: To use this model please remember the following things
39
+ 1. The model is based on BAAI/bge-m3; You need to obtain the weights of this model before you can use the classifier
40
+ 2. To load the model weights you need to pass the base model and tokenizer to the classifiers constructor
41
+
42
+
43
+
44
 
45
  - **Developed by:** [philipp-zettl](https://huggingface.co/philipp-zettl/)
46
  - **Funded by [optional]:** [More Information Needed]