danielfein commited on
Commit
81e7bc1
·
verified ·
1 Parent(s): d58850e

Document direct story scoring usage

Browse files
Files changed (1) hide show
  1. README.md +6 -15
README.md CHANGED
@@ -12,20 +12,12 @@ license: llama3.1
12
 
13
  # Llama 8B Creative Writing Verifier
14
 
15
- This model is a `LlamaForSequenceClassification` reward model for scoring creative-writing prompt/story pairs. It should be used as a scalar verifier/reward model, not as a text-generation model.
16
 
17
 
18
  ## Usage
19
 
20
- This is a reward model, not a text-generation model. Load it with `AutoModelForSequenceClassification` and score each prompt/story pair as raw text in this format:
21
-
22
- ```text
23
- {prompt}
24
-
25
- {story}
26
- ```
27
-
28
- Do not apply a chat template for scoring. Higher scalar scores indicate the model's preferred story.
29
 
30
  ```python
31
  import torch
@@ -44,10 +36,9 @@ if tokenizer.pad_token is None:
44
  if model.config.pad_token_id is None:
45
  model.config.pad_token_id = tokenizer.pad_token_id
46
 
47
- def reward(prompt: str, story: str) -> float:
48
- text = f"{prompt.strip()}\n\n{story.strip()}"
49
  inputs = tokenizer(
50
- text,
51
  return_tensors="pt",
52
  truncation=True,
53
  max_length=4096,
@@ -55,8 +46,8 @@ def reward(prompt: str, story: str) -> float:
55
  with torch.inference_mode():
56
  return model(**inputs).logits.squeeze(-1).float().item()
57
 
58
- chosen_score = reward(prompt, chosen_story)
59
- rejected_score = reward(prompt, rejected_story)
60
  print(chosen_score > rejected_score)
61
  ```
62
 
 
12
 
13
  # Llama 8B Creative Writing Verifier
14
 
15
+ This model is a `LlamaForSequenceClassification` reward model for scoring creative-writing stories. It should be used as a scalar verifier/reward model, not as a text-generation model.
16
 
17
 
18
  ## Usage
19
 
20
+ This is a reward model, not a text-generation model. Load it with `AutoModelForSequenceClassification` and score the story directly as raw text. Do not apply a chat template or wrap the story in a prompt.
 
 
 
 
 
 
 
 
21
 
22
  ```python
23
  import torch
 
36
  if model.config.pad_token_id is None:
37
  model.config.pad_token_id = tokenizer.pad_token_id
38
 
39
+ def reward(story: str) -> float:
 
40
  inputs = tokenizer(
41
+ story.strip(),
42
  return_tensors="pt",
43
  truncation=True,
44
  max_length=4096,
 
46
  with torch.inference_mode():
47
  return model(**inputs).logits.squeeze(-1).float().item()
48
 
49
+ chosen_score = reward(chosen_story)
50
+ rejected_score = reward(rejected_story)
51
  print(chosen_score > rejected_score)
52
  ```
53