delineiro commited on
Commit
0ae2381
1 Parent(s): efa14e3

Actualización de modelo

Browse files
Files changed (4) hide show
  1. config.json +8 -18
  2. inference.py +15 -32
  3. model.pkl +1 -1
  4. vectorizer.pkl +1 -1
config.json CHANGED
@@ -1,20 +1,10 @@
1
  {
2
- "architectures": ["AutoModelForSequenceClassification", "AutoModelForCausalLM"],
3
- "model_type": "bert",
4
- "classification_model_name": "delineiro/soflexpoc",
5
- "generation_model_name": "delineiro/soflexpoc",
6
  "language": "es",
7
- "max_position_embeddings": 512,
8
- "num_attention_heads": 12,
9
- "num_hidden_layers": 12,
10
- "pad_token_id": 0,
11
- "vocab_size": 30522,
12
- "hidden_size": 768,
13
- "intermediate_size": 3072,
14
- "hidden_act": "gelu",
15
- "hidden_dropout_prob": 0.1,
16
- "attention_probs_dropout_prob": 0.1,
17
- "max_length": 100,
18
- "do_sample": true,
19
- "num_return_sequences": 1
20
- }
 
1
  {
2
+ "model_name": "Spanish Text Classification Model",
3
+ "model_type": "sklearn",
4
+ "framework": "sklearn",
5
+ "task": "text-classification",
6
  "language": "es",
7
+ "vectorizer": "TfidfVectorizer",
8
+ "classifier": "MultinomialNB",
9
+ "version": "1.0.0"
10
+ }
 
 
 
 
 
 
 
 
 
 
inference.py CHANGED
@@ -1,37 +1,20 @@
1
- import joblib
2
- import numpy as np
3
-
4
- # Cargar el vectorizador
5
- try:
6
- with open('vectorizer.pkl', 'rb') as f:
7
- vectorizer = joblib.load(f)
8
- except Exception as e:
9
- print(f"Error al cargar el vectorizador: {e}")
10
 
11
- # Cargar el modelo
12
- try:
13
- with open('model.pkl', 'rb') as f:
14
- model = joblib.load(f)
15
- except Exception as e:
16
- print(f"Error al cargar el modelo: {e}")
17
 
18
- def preprocess(text):
19
- """Preprocesa el texto para la inferencia."""
20
- try:
21
- return vectorizer.transform([text])
22
- except Exception as e:
23
- print(f"Error en el preprocesamiento: {e}")
24
 
25
  def predict(text):
26
- """Realiza la predicción a partir del texto ingresado."""
27
- try:
28
- X = preprocess(text)
29
- return model.predict(X)
30
- except Exception as e:
31
- print(f"Error en la predicción: {e}")
32
 
33
- if __name__ == "__main__":
34
- # Prueba del modelo
35
- test_text = "Texto de prueba para predecir"
36
- result = predict(test_text)
37
- print(f"Predicción: {result}")
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ import joblib
 
 
 
 
 
3
 
4
+ def load_model_and_vectorizer():
5
+ model = joblib.load('model.pkl')
6
+ vectorizer = joblib.load('vectorizer.pkl')
7
+ return model, vectorizer
 
 
8
 
9
  def predict(text):
10
+ model, vectorizer = load_model_and_vectorizer()
11
+ text_vectorized = vectorizer.transform([text])
12
+ prediction = model.predict(text_vectorized)
13
+ return prediction[0]
 
 
14
 
15
+ if __name__ == '__main__':
16
+ # Example usage
17
+ text = "Ejemplo de declaraci�n"
18
+ result = predict(text)
19
+ print(f"Categor�a predicha: {result}")
20
+
model.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6566d630fd91a6406a0b60465fd1941d1a475655c53088aeae71e38c4662515d
3
  size 7103071
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e5910e6d9fdc5fd8f6ed1cceeda5bfb8dac91905e61c0bd01dbf7a6c39b416f6
3
  size 7103071
vectorizer.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e74c46f64f2513cc152fc1751b0fa1d8cb0015576b800a7ec4d3ded27b490bb6
3
  size 1123551
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d38d53585deb8d0789ce2a229e8a000849900a1cedf8c91b9c9d7d1d2f76cfb
3
  size 1123551