dewmal commited on
Commit
0d55260
·
verified ·
1 Parent(s): 8bc3969

Upload Concept Memory base model

Browse files
Files changed (1) hide show
  1. README.md +33 -3
README.md CHANGED
@@ -23,15 +23,22 @@ not a language model pretrained from scratch. Its text encoder is
23
  - `model.pt`: PyTorch state dictionary and training metadata.
24
  - `config.json`: encoder, task, and training run metadata.
25
 
26
- ## Load the checkpoint
27
 
28
- Install this project's dependencies, then load it with the repository's model
29
- class:
 
 
 
 
 
 
30
 
31
  ```python
32
  import torch
33
  from huggingface_hub import hf_hub_download
34
  from concept_memory import ConceptMemoryModel
 
35
 
36
  repo_id = "Syigen/rgcm"
37
  checkpoint = hf_hub_download(repo_id, "model.pt")
@@ -43,6 +50,27 @@ model = ConceptMemoryModel.from_pretrained(
43
  )
44
  model.load_state_dict(payload["model_state_dict"])
45
  model.eval()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  ```
47
 
48
  The Hub checkpoint is a PyTorch artifact for this project's Python package; it
@@ -50,6 +78,7 @@ is not directly compatible with `transformers.AutoModel.from_pretrained`.
50
 
51
  ## Training metadata
52
 
 
53
  {
54
  "datasets": [
55
  "mteb/banking77",
@@ -66,3 +95,4 @@ is not directly compatible with `transformers.AutoModel.from_pretrained`.
66
  "batch_size": 16,
67
  "seed": 42
68
  }
 
 
23
  - `model.pt`: PyTorch state dictionary and training metadata.
24
  - `config.json`: encoder, task, and training run metadata.
25
 
26
+ ## Run a prediction
27
 
28
+ Use Python 3.11 or newer. Install the model code and the Hub client:
29
+
30
+ ```bash
31
+ pip install "git+https://github.com/ceylonai/rgcm.git" huggingface_hub
32
+ ```
33
+
34
+ Download the checkpoint, construct a question with the criteria you want the
35
+ model to judge, and inspect its prediction and probabilities:
36
 
37
  ```python
38
  import torch
39
  from huggingface_hub import hf_hub_download
40
  from concept_memory import ConceptMemoryModel
41
+ from concept_memory.types import Question
42
 
43
  repo_id = "Syigen/rgcm"
44
  checkpoint = hf_hub_download(repo_id, "model.pt")
 
50
  )
51
  model.load_state_dict(payload["model_state_dict"])
52
  model.eval()
53
+
54
+ question = Question(
55
+ id="intent",
56
+ type="choice",
57
+ instructions="Which team should handle this customer request?",
58
+ criteria=[
59
+ {"id": "billing", "description": "Payment or subscription issues"},
60
+ {"id": "technical", "description": "Bugs or integration problems"},
61
+ {"id": "sales", "description": "Pricing or account questions"},
62
+ ],
63
+ )
64
+
65
+ with torch.inference_mode():
66
+ result = model.predict(
67
+ "Stripe integration keeps failing after several attempts.", [question]
68
+ )[0]
69
+
70
+ criteria = question.normalized_criteria()
71
+ predicted = criteria[result.prediction.item()]
72
+ print("Prediction:", predicted.id, "-", predicted.description)
73
+ print("Probabilities:", result.probabilities.tolist())
74
  ```
75
 
76
  The Hub checkpoint is a PyTorch artifact for this project's Python package; it
 
78
 
79
  ## Training metadata
80
 
81
+ ```json
82
  {
83
  "datasets": [
84
  "mteb/banking77",
 
95
  "batch_size": 16,
96
  "seed": 42
97
  }
98
+ ```