Oleg Shulyakov commited on
Commit
f0c5d5e
·
1 Parent(s): 6475b9d

Update _generate_readme

Browse files
Files changed (1) hide show
  1. app.py +13 -15
app.py CHANGED
@@ -337,51 +337,49 @@ class HuggingFaceModelProcessor:
337
 
338
  return new_repo_url
339
 
340
- def _generate_readme(self, outdir: str, token: str, model_id: str,
341
- new_repo_id: str, gguf_name: str) -> str:
342
  """Generate README.md for the quantized model."""
343
- creator = self._get_model_creator(model_id)
344
- model_name = self._get_model_name(model_id)
345
- username = whoami(token)["name"]
346
 
347
  try:
348
- card = ModelCard.load(model_id, token=token)
349
  except:
350
  card = ModelCard("")
351
 
352
  if card.data.tags is None:
353
  card.data.tags = []
354
  card.data.tags.extend(["llama-cpp", "gguf-my-repo"])
355
- card.data.base_model = model_id
356
 
357
  card.text = dedent(
358
  f"""
359
- # {model_name}
360
  **Model creator:** [{creator}](https://huggingface.co/{creator})<br/>
361
- **Original model**: [{model_id}](https://huggingface.co/{model_id})<br/>
362
  **GGUF quantization:** provided by [{username}](https:/huggingface.co/{username}) using `llama.cpp`<br/>
363
  ## Special thanks
364
  🙏 Special thanks to [Georgi Gerganov](https://github.com/ggerganov) and the whole team working on [llama.cpp](https://github.com/ggerganov/llama.cpp/) for making all of this possible.
365
  ## Use with Ollama
366
  ```bash
367
- ollama run "hf.co/{new_repo_id}:<quantization>"
368
  ```
369
  ## Use with LM Studio
370
  ```bash
371
- lms load "{new_repo_id}"
372
  ```
373
  ## Use with llama.cpp CLI
374
  ```bash
375
- llama-cli --hf-repo "{new_repo_id}" --hf-file "{gguf_name}" -p "The meaning to life and the universe is"
376
  ```
377
  ## Use with llama.cpp Server:
378
  ```bash
379
- llama-server --hf-repo "{new_repo_id}" --hf-file "{gguf_name}" -c 4096
380
  ```
381
  """
382
  )
383
 
384
- readme_path = f"{outdir}/README.md"
385
  card.save(readme_path)
386
  return readme_path
387
 
@@ -422,7 +420,7 @@ llama-server --hf-repo "{new_repo_id}" --hf-file "{gguf_name}" -c 4096
422
  raise GGUFConverterError(f"Error uploading imatrix.dat: {e}")
423
 
424
  # Upload README.md
425
- readme_path = self._generate_readme(processing_config.outdir, processing_config.token, processing_config.model_id, processing_config.new_repo_id, output_config.filename)
426
  self._upload_file(processing_config, readme_path, "README.md")
427
 
428
  print(f"Uploaded successfully with {quant_config.imatrix_method if quant_config.use_imatrix else quant_config.method} option!")
 
337
 
338
  return new_repo_url
339
 
340
+ def _generate_readme(self, processing_config :ModelProcessingConfig) -> str:
 
341
  """Generate README.md for the quantized model."""
342
+ creator = self._get_model_creator(processing_config.model_id)
343
+ username = whoami(processing_config.token)["name"]
 
344
 
345
  try:
346
+ card = ModelCard.load(processing_config.model_id, token=processing_config.token)
347
  except:
348
  card = ModelCard("")
349
 
350
  if card.data.tags is None:
351
  card.data.tags = []
352
  card.data.tags.extend(["llama-cpp", "gguf-my-repo"])
353
+ card.data.base_model = processing_config.model_id
354
 
355
  card.text = dedent(
356
  f"""
357
+ # {processing_config.model_name}
358
  **Model creator:** [{creator}](https://huggingface.co/{creator})<br/>
359
+ **Original model**: [{processing_config.model_id}](https://huggingface.co/{processing_config.model_id})<br/>
360
  **GGUF quantization:** provided by [{username}](https:/huggingface.co/{username}) using `llama.cpp`<br/>
361
  ## Special thanks
362
  🙏 Special thanks to [Georgi Gerganov](https://github.com/ggerganov) and the whole team working on [llama.cpp](https://github.com/ggerganov/llama.cpp/) for making all of this possible.
363
  ## Use with Ollama
364
  ```bash
365
+ ollama run "hf.co/{processing_config.new_repo_id}:<quantization>"
366
  ```
367
  ## Use with LM Studio
368
  ```bash
369
+ lms load "{processing_config.new_repo_id}"
370
  ```
371
  ## Use with llama.cpp CLI
372
  ```bash
373
+ llama-cli --hf-repo "{processing_config.new_repo_id}" --hf-file "{processing_config.output_config.filename}" -p "The meaning to life and the universe is"
374
  ```
375
  ## Use with llama.cpp Server:
376
  ```bash
377
+ llama-server --hf-repo "{processing_config.new_repo_id}" --hf-file "{processing_config.output_config.filename}" -c 4096
378
  ```
379
  """
380
  )
381
 
382
+ readme_path = f"{processing_config.outdir}/README.md"
383
  card.save(readme_path)
384
  return readme_path
385
 
 
420
  raise GGUFConverterError(f"Error uploading imatrix.dat: {e}")
421
 
422
  # Upload README.md
423
+ readme_path = self._generate_readme(processing_config)
424
  self._upload_file(processing_config, readme_path, "README.md")
425
 
426
  print(f"Uploaded successfully with {quant_config.imatrix_method if quant_config.use_imatrix else quant_config.method} option!")