mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-08-08 18:06:37 +08:00
fix: string indentation with textwrap.dedent
(#510)
* fix: string indentation with textwrap.dedent * update formatting
This commit is contained in:
parent
f03c8a7b44
commit
3acc1ec84e
@ -8,6 +8,7 @@ import logging
|
||||
import shutil
|
||||
import time
|
||||
from pathlib import Path
|
||||
from textwrap import dedent
|
||||
from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union
|
||||
|
||||
import mlx.core as mx
|
||||
@ -437,23 +438,25 @@ def upload_to_hub(path: str, upload_repo: str, hf_path: str):
|
||||
|
||||
card = ModelCard.load(hf_path)
|
||||
card.data.tags = ["mlx"] if card.data.tags is None else card.data.tags + ["mlx"]
|
||||
card.text = f"""
|
||||
# {upload_repo}
|
||||
This model was converted to MLX format from [`{hf_path}`]().
|
||||
Refer to the [original model card](https://huggingface.co/{hf_path}) for more details on the model.
|
||||
## Use with mlx
|
||||
card.text = dedent(
|
||||
f"""
|
||||
# {upload_repo}
|
||||
This model was converted to MLX format from [`{hf_path}`]().
|
||||
Refer to the [original model card](https://huggingface.co/{hf_path}) for more details on the model.
|
||||
## Use with mlx
|
||||
|
||||
```bash
|
||||
pip install mlx-lm
|
||||
```
|
||||
```bash
|
||||
pip install mlx-lm
|
||||
```
|
||||
|
||||
```python
|
||||
from mlx_lm import load, generate
|
||||
```python
|
||||
from mlx_lm import load, generate
|
||||
|
||||
model, tokenizer = load("{upload_repo}")
|
||||
response = generate(model, tokenizer, prompt="hello", verbose=True)
|
||||
```
|
||||
"""
|
||||
model, tokenizer = load("{upload_repo}")
|
||||
response = generate(model, tokenizer, prompt="hello", verbose=True)
|
||||
```
|
||||
"""
|
||||
)
|
||||
card.save(os.path.join(path, "README.md"))
|
||||
|
||||
logging.set_verbosity_info()
|
||||
|
Loading…
Reference in New Issue
Block a user