Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

`vespa` tutorial : ./src/python/user_search.py U33527 10 KeyError: 'children'

I’m following step by step the Vespa tutorials: https://docs.vespa.ai/en/tutorials/news-5-recommendation.html

(vespa) raphy@pc:~/vespa/sample-apps/news$ python3 src/python/train_cold_start.py mind 10
Total loss after epoch 9: 534.6995239257812 (0.4087916910648346 avg)
{'auc': 0.8578, 'mrr': 0.4789, 'ndcg@5': 0.5482, 'ndcg@10': 0.6013}
{'auc': 0.6265, 'mrr': 0.2846, 'ndcg@5': 0.3117, 'ndcg@10': 0.3747}
Total loss after epoch 10: 517.1571044921875 (0.39538004994392395 avg)
{'auc': 0.8758, 'mrr': 0.5073, 'ndcg@5': 0.5817, 'ndcg@10': 0.6315}
{'auc': 0.6246, 'mrr': 0.2843, 'ndcg@5': 0.3113, 'ndcg@10': 0.3732}
(vespa) raphy@pc:~/vespa/sample-apps/news$ 

But I’m encountering this problem:

(vespa) raphy@pc:~/vespa/sample-apps/news$ ./src/python/user_search.py U33527 10
Traceback (most recent call last):
  File "./src/python/user_search.py", line 58, in <module>
    main()
  File "./src/python/user_search.py", line 51, in main
    user_vector = query_user_embedding(user_id)
  File "./src/python/user_search.py", line 21, in query_user_embedding
    embedding = parse_embedding(result["root"]["children"][0])
KeyError: 'children'
(vespa) raphy@pc:~/vespa/sample-apps/news$ 


(vespa) raphy@pc:~/vespa/sample-apps/news$ grep "U33527" mind/vespa_user_embeddings.json
{"put": "id:user:user::U33527", "fields": {"user_id":"U33527", "embedding": {"values": [0.000000,0.060903,0.158397,0.003585,0.230960,0.005171,-0.300856,-0.295116,-0.042150,-0.416067,-0.173345,-0.241960,-0.140207,-0.000399,0.463869,-0.294422,-0.080257,-0.208765,-0.070218,0.189583,0.031040,-0.073909,-0.147883,-0.164819,-0.229605,-0.248327,0.174647,-0.168265,-0.370106,-0.209611,-0.206252,-0.288447,0.091576,-0.122662,0.000394,0.172982,-0.147844,0.326629,-0.103831,-0.312612,-0.209032,0.190745,-0.335539,0.261593,0.699852,0.041234,0.241921,0.052331,0.103968,-0.216830,-0.279406]} }},

OS: Ubuntu 20.04

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How to solve it ?

>Solution :

The Vespa index has no user documents here, so most likely the user and news embeddings have not been fed to the system. After they are calculated in the previous step (https://docs.vespa.ai/en/tutorials/news-4-embeddings.html), be sure to feed them to Vespa:

$ java -jar vespa-http-client-jar-with-dependencies.jar \
       --file mind/vespa_user_embeddings.json \
       --endpoint http://localhost:8080
$ java -jar vespa-http-client-jar-with-dependencies.jar \
       --file mind/vespa_news_embeddings.json \
       --endpoint http://localhost:8080

That will solve the problem.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading