mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-08-09 02:16: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 shutil
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from textwrap import dedent
|
||||||
from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union
|
from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union
|
||||||
|
|
||||||
import mlx.core as mx
|
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 = ModelCard.load(hf_path)
|
||||||
card.data.tags = ["mlx"] if card.data.tags is None else card.data.tags + ["mlx"]
|
card.data.tags = ["mlx"] if card.data.tags is None else card.data.tags + ["mlx"]
|
||||||
card.text = f"""
|
card.text = dedent(
|
||||||
# {upload_repo}
|
f"""
|
||||||
This model was converted to MLX format from [`{hf_path}`]().
|
# {upload_repo}
|
||||||
Refer to the [original model card](https://huggingface.co/{hf_path}) for more details on the model.
|
This model was converted to MLX format from [`{hf_path}`]().
|
||||||
## Use with mlx
|
Refer to the [original model card](https://huggingface.co/{hf_path}) for more details on the model.
|
||||||
|
## Use with mlx
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install mlx-lm
|
pip install mlx-lm
|
||||||
```
|
```
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from mlx_lm import load, generate
|
from mlx_lm import load, generate
|
||||||
|
|
||||||
model, tokenizer = load("{upload_repo}")
|
model, tokenizer = load("{upload_repo}")
|
||||||
response = generate(model, tokenizer, prompt="hello", verbose=True)
|
response = generate(model, tokenizer, prompt="hello", verbose=True)
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
)
|
||||||
card.save(os.path.join(path, "README.md"))
|
card.save(os.path.join(path, "README.md"))
|
||||||
|
|
||||||
logging.set_verbosity_info()
|
logging.set_verbosity_info()
|
||||||
|
Loading…
Reference in New Issue
Block a user