Granite Library
Safetensors
GGUF
English
kndtran commited on
Commit
7932323
·
1 Parent(s): 2fff1a7

fix: Change max_completion_tokens to max_tokens in io.yaml conversion script.

Browse files
_ollama/convert_io_yaml_files.py CHANGED
@@ -8,7 +8,6 @@ import copy
8
  import json
9
  import yaml
10
 
11
-
12
  # No automated way, just add mappings here as needed.
13
  MAP_MODELS_HF_TO_OLLAMA = {
14
  "granite-3.3-8b-instruct": "granite3.3:8b",
@@ -18,12 +17,16 @@ MAP_COLON = "_"
18
  LORA_TYPES = ["lora", "alora"]
19
  IO_FILE_NAME = "io.yaml"
20
 
21
-
22
  def find_all_model_paths(model_name: str) -> List[Path]:
23
  """Find all paths with the given model name.
24
  """
25
  current = Path(".")
26
- return sorted([p for p in current.rglob(model_name) if p.is_dir()])
 
 
 
 
 
27
 
28
  def map_model_path_hf_to_ollama(model_name: str, hf_path: Path) -> Path:
29
  """Replace HF model name in the model path to Ollama model name.
@@ -52,6 +55,12 @@ def convert_io_yaml_hf_to_ollama(hf_path: Path, ollama_path: Path):
52
  # Set movement of documents into message roles
53
  ollama_yaml["docs_as_message"] = "roles"
54
 
 
 
 
 
 
 
55
  with ollama_path.open("w") as f:
56
  yaml.dump(ollama_yaml, f, default_style=False)
57
 
@@ -79,7 +88,6 @@ def convert_lora_adapters(model_name: str, model_paths: List[Path]):
79
  ollama_lora_path.mkdir(parents=True, exist_ok=True)
80
  convert_io_yaml_hf_to_ollama(hf_io_file_path, ollama_io_file_path)
81
 
82
-
83
  def main():
84
  """Main function.
85
  """
@@ -97,6 +105,7 @@ def main():
97
  )
98
 
99
  model_paths = find_all_model_paths(model_name)
 
100
 
101
  print(f"Found {len(model_paths)} intrinsics for {model_name}:")
102
  for model_path in model_paths:
 
8
  import json
9
  import yaml
10
 
 
11
  # No automated way, just add mappings here as needed.
12
  MAP_MODELS_HF_TO_OLLAMA = {
13
  "granite-3.3-8b-instruct": "granite3.3:8b",
 
17
  LORA_TYPES = ["lora", "alora"]
18
  IO_FILE_NAME = "io.yaml"
19
 
 
20
  def find_all_model_paths(model_name: str) -> List[Path]:
21
  """Find all paths with the given model name.
22
  """
23
  current = Path(".")
24
+ paths = []
25
+ for p in current.rglob(model_name):
26
+ rp = p.relative_to(current).parts
27
+ if p.is_dir() and not (rp[0].startswith("_") or rp[0].startswith("_")):
28
+ paths.append(p)
29
+ return sorted(paths)
30
 
31
  def map_model_path_hf_to_ollama(model_name: str, hf_path: Path) -> Path:
32
  """Replace HF model name in the model path to Ollama model name.
 
55
  # Set movement of documents into message roles
56
  ollama_yaml["docs_as_message"] = "roles"
57
 
58
+ # Change to max_tokens as max_completion_tokens is not yet supported:
59
+ # https://github.com/ollama/ollama/issues/7125
60
+ if "max_completion_tokens" in ollama_yaml["parameters"]:
61
+ ollama_yaml["parameters"]["max_tokens"] = ollama_yaml["parameters"]["max_completion_tokens"]
62
+ del ollama_yaml["parameters"]["max_completion_tokens"]
63
+
64
  with ollama_path.open("w") as f:
65
  yaml.dump(ollama_yaml, f, default_style=False)
66
 
 
88
  ollama_lora_path.mkdir(parents=True, exist_ok=True)
89
  convert_io_yaml_hf_to_ollama(hf_io_file_path, ollama_io_file_path)
90
 
 
91
  def main():
92
  """Main function.
93
  """
 
105
  )
106
 
107
  model_paths = find_all_model_paths(model_name)
108
+ print(model_paths)
109
 
110
  print(f"Found {len(model_paths)} intrinsics for {model_name}:")
111
  for model_path in model_paths:
answer_relevance_classifier/granite4_micro/lora/io.yaml CHANGED
@@ -2,7 +2,7 @@ docs_as_message: roles
2
  instruction: answer_relevance
3
  model: null
4
  parameters:
5
- max_completion_tokens: 1024
6
  response_format:
7
  properties:
8
  answer_relevance_analysis:
 
2
  instruction: answer_relevance
3
  model: null
4
  parameters:
5
+ max_tokens: 1024
6
  response_format:
7
  properties:
8
  answer_relevance_analysis:
answer_relevance_rewriter/granite4_micro/lora/io.yaml CHANGED
@@ -14,7 +14,7 @@ instruction: "Rewrite the response for relevance.\nThe last assistant response i
14
  \ their inquiry, in place of the original response.\n"
15
  model: null
16
  parameters:
17
- max_completion_tokens: 1024
18
  response_format:
19
  properties:
20
  answer_relevance_rewrite:
 
14
  \ their inquiry, in place of the original response.\n"
15
  model: null
16
  parameters:
17
+ max_tokens: 1024
18
  response_format:
19
  properties:
20
  answer_relevance_rewrite:
answerability/granite4_micro/alora/io.yaml CHANGED
@@ -2,7 +2,7 @@ docs_as_message: roles
2
  instruction: null
3
  model: null
4
  parameters:
5
- max_completion_tokens: 6
6
  response_format:
7
  enum:
8
  - answerable
 
2
  instruction: null
3
  model: null
4
  parameters:
5
+ max_tokens: 6
6
  response_format:
7
  enum:
8
  - answerable
answerability/granite4_micro/lora/io.yaml CHANGED
@@ -2,7 +2,7 @@ docs_as_message: roles
2
  instruction: null
3
  model: null
4
  parameters:
5
- max_completion_tokens: 6
6
  response_format:
7
  enum:
8
  - answerable
 
2
  instruction: null
3
  model: null
4
  parameters:
5
+ max_tokens: 6
6
  response_format:
7
  enum:
8
  - answerable
citations/granite4_micro/lora/io.yaml CHANGED
@@ -8,7 +8,7 @@ instruction: 'Split the last assistant response into individual sentences. For
8
  '
9
  model: null
10
  parameters:
11
- max_completion_tokens: 4096
12
  response_format:
13
  $defs:
14
  _MODEL_OUTPUT_ENTRY:
 
8
  '
9
  model: null
10
  parameters:
11
+ max_tokens: 4096
12
  response_format:
13
  $defs:
14
  _MODEL_OUTPUT_ENTRY:
hallucination_detection/granite4_micro/lora/io.yaml CHANGED
@@ -9,7 +9,7 @@ instruction: 'Split the last assistant response into individual sentences. For e
9
  '
10
  model: null
11
  parameters:
12
- max_completion_tokens: 4096
13
  response_format:
14
  $defs:
15
  HallucinationOutputEntry:
 
9
  '
10
  model: null
11
  parameters:
12
+ max_tokens: 4096
13
  response_format:
14
  $defs:
15
  HallucinationOutputEntry:
query_rewrite/granite4_micro/lora/io.yaml CHANGED
@@ -2,7 +2,7 @@ docs_as_message: roles
2
  instruction: null
3
  model: null
4
  parameters:
5
- max_completion_tokens: 1024
6
  response_format:
7
  properties:
8
  rewritten_question:
 
2
  instruction: null
3
  model: null
4
  parameters:
5
+ max_tokens: 1024
6
  response_format:
7
  properties:
8
  rewritten_question: