diff --git a/src/heretic/main.py b/src/heretic/main.py index 50befc7..016c392 100644 --- a/src/heretic/main.py +++ b/src/heretic/main.py @@ -823,11 +823,23 @@ def run(): token=token, ) - # If the model path doesn't exist locally, it can be assumed - # to be a model hosted on the Hugging Face Hub, in which case + # If the model path exists locally and includes the + # card, use it directly. If the model path doesn't + # exist locally, it can be assumed to be a model + # hosted on the Hugging Face Hub, in which case # we can retrieve the model card. - if not Path(settings.model).exists(): + model_path = Path(settings.model) + if model_path.exists(): + card_path = ( + model_path / huggingface_hub.constants.REPOCARD_NAME + ) + if card_path.exists(): + card = ModelCard.load(card_path) + else: + card = None + else: card = ModelCard.load(settings.model) + if card is not None: if card.data is None: card.data = ModelCardData() if card.data.tags is None: diff --git a/src/heretic/utils.py b/src/heretic/utils.py index e706c5c..a0d5f35 100644 --- a/src/heretic/utils.py +++ b/src/heretic/utils.py @@ -271,7 +271,11 @@ def get_readme_intro( base_refusals: int, bad_prompts: list[Prompt], ) -> str: - model_link = f"[{settings.model}](https://huggingface.co/{settings.model})" + if Path(settings.model).exists(): + # Hide the path, which may contain private information. + model_link = "a model" + else: + model_link = f"[{settings.model}](https://huggingface.co/{settings.model})" return f"""# This is a decensored version of { model_link