File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -1885,8 +1885,9 @@ def from_pretrained(
1885
1885
cls ,
1886
1886
repo_id : str ,
1887
1887
filename : Optional [str ],
1888
- local_dir : Optional [Union [str , os .PathLike [str ]]] = "." ,
1888
+ local_dir : Optional [Union [str , os .PathLike [str ]]] = None ,
1889
1889
local_dir_use_symlinks : Union [bool , Literal ["auto" ]] = "auto" ,
1890
+ cache_dir : Optional [Union [str , os .PathLike [str ]]] = None ,
1890
1891
** kwargs : Any ,
1891
1892
) -> "Llama" :
1892
1893
"""Create a Llama model from a pretrained model name or path.
@@ -1945,18 +1946,29 @@ def from_pretrained(
1945
1946
subfolder = str (Path (matching_file ).parent )
1946
1947
filename = Path (matching_file ).name
1947
1948
1948
- local_dir = "."
1949
-
1950
1949
# download the file
1951
1950
hf_hub_download (
1952
1951
repo_id = repo_id ,
1953
- local_dir = local_dir ,
1954
1952
filename = filename ,
1955
1953
subfolder = subfolder ,
1954
+ local_dir = local_dir ,
1956
1955
local_dir_use_symlinks = local_dir_use_symlinks ,
1956
+ cache_dir = cache_dir ,
1957
1957
)
1958
1958
1959
- model_path = os .path .join (local_dir , filename )
1959
+ if local_dir is None :
1960
+ model_path = hf_hub_download (
1961
+ repo_id = repo_id ,
1962
+ filename = filename ,
1963
+ subfolder = subfolder ,
1964
+ local_dir = local_dir ,
1965
+ local_dir_use_symlinks = local_dir_use_symlinks ,
1966
+ cache_dir = cache_dir ,
1967
+ local_files_only = True ,
1968
+
1969
+ )
1970
+ else :
1971
+ model_path = os .path .join (local_dir , filename )
1960
1972
1961
1973
return cls (
1962
1974
model_path = model_path ,
You can’t perform that action at this time.
0 commit comments