QUESTO CODICE from transformers import pipeline Creiamo una pipeline "text-generation"…
- User
QUESTO CODICE
from transformers import pipeline
Creiamo una pipeline "text-generation" con il modello predefinito.
pipe = pipeline("text-generation", model="/content/drive/Shareddrives/Mistral_8x7b")
Definiamo un prompt iniziale per la generazione del testo.
prompt = "Il futuro della tecnologia è" return_tensors="pt"
Generiamo le sequenze di testo usando la pipeline.
max_length determina la lunghezza massima del testo da generare (incluso il prompt),
e num_return_sequences indica quante varianti del testo generare.
generated_texts = pipe(prompt, max_length=50, num_return_sequences=1)
Stampiamo le sequenze generate. In questo esempio stamperemo solo una sequenza,
ma puoi specificare un numero maggiore nel parametro num_return_sequences se desideri.
for generated in generated_texts: print(generated['generated_text'])
DA QUESTO ERRORE:
HFValidationError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/transformers/utils/hub.py in cached_file(path_or_repo_id, filename, cache_dir, force_download, resume_download, proxies, token, revision, local_files_only, subfolder, repo_type, user_agent, _raise_exceptions_for_missing_entries, _raise_exceptions_for_connection_errors, _commit_hash, **deprecated_kwargs) 388 # Load from URL or cache if already cached --> 389 resolved_file = hf_hub_download( 390 path_or_repo_id,
4 frames HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': '/content/drive/Shareddrives/Mistral_8x7b'. Use
repo_typeargument if needed.The above exception was the direct cause of the following exception:
OSError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/transformers/utils/hub.py in cached_file(path_or_repo_id, filename, cache_dir, force_download, resume_download, proxies, token, revision, local_files_only, subfolder, repo_type, user_agent, _raise_exceptions_for_missing_entries, _raise_exceptions_for_connection_errors, _commit_hash, **deprecated_kwargs) 452 raise EnvironmentError(f"There was a specific connection error when trying to load {path_or_repo_id}:\n{err}") 453 except HFValidationError as e: --> 454 raise EnvironmentError( 455 f"Incorrect path_or_model_id: '{path_or_repo_id}'. Please provide either the path to a local folder or the repo_id of a model on the Hub." 456 ) from e
OSError: Incorrect path_or_model_id: '/content/drive/Shareddrives/Mistral_8x7b'. Please provide either the path to a local folder or the repo_id of a model on the Hub.
- Assistant
L'errore
HFValidationErrorche stai riscontrando è dovuto al fatto che hai specificato un percorso di file system (/content/drive/Shareddrives/Mistral_8x7b) come identificativo del modello nel metodopipeline. Per usare un modello personalizzato che risiede in un file system locale o su una piattaforma come Google Drive, devi assicurarti di: