Open alicesaunders opened 1 year ago
Hi @alicesaunders,
Can you please try to make your example smaller and something I can run locally to reproduce the error?
At a quick glance it looks like there is unmodified python code in the R script (e.g, usage of .
and {
in ds.map
, etc.). Also, the python function import_libraries()
seems to me coming from a misunderstanding of the difference in scoping rules between python and R; import
does not make the package symbols globally available like library()
does in R.
(This issue thread is more for reporting bugs than for support).
When running the code below I am repeatedly getting the following error: Error in py_call_impl(callable, dots$args, dots$keywords) : NameError: name 'faiss' is not defined
I have two scripts, app.R and pythonSemanticSearch.py. Some lines are commented out as they are alternative functions I have tried to use to see if it fixes the error but it has remained the same. My original code is using an index generated and saved by another script that is then being read in here (I will keep the code for this commented out but have replaced it with a different dataset and index generated within this code for reproducibility). A different dataset was used to generate this index and replaces the variable df in the example code below.
Here is the code from app.R:
and here is the code from pythonSemanticSearch.py:
python script for the app - functions to read in the model
Here is the output from:
reticulate::py_config()
NOTE: Python version was forced by RETICULATE_PYTHON
here is the output from
utils::SessionInfo()
R version 4.0.4 (2021-02-15) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22621)
Matrix products: default
locale: [1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] reticulate_1.24 shiny_1.6.0
loaded via a namespace (and not attached): [1] Rcpp_1.0.8.3 rstudioapi_0.13 magrittr_2.0.1 rappdirs_0.3.3 xtable_1.8-4
[6] lattice_0.20-41 R6_2.5.0 rlang_0.4.10 fastmap_1.1.0 tools_4.0.4
[11] grid_4.0.4 png_0.1-7 jquerylib_0.1.3 withr_2.4.1 htmltools_0.5.1.1 [16] ellipsis_0.3.1 digest_0.6.27 lifecycle_1.0.0 crayon_1.4.1 Matrix_1.2-18
[21] later_1.1.0.1 sass_0.4.1 promises_1.2.0.1 cachem_1.0.4 mime_0.10
[26] compiler_4.0.4 bslib_0.2.4 jsonlite_1.7.2 httpuv_1.5.5
The model and index used are files that I have already generated in a previous script. A base model from SentenceTransformers can be used instead e.g. model <- SentenceTransformer('multi-qa-distilbert-cos-v1').