ValueError: could not convert string to float: 'message' - Q&A


I’m trying to run the notebook for the exercise on Building a Q&A system, but I get a value error halfway down

ValueError: could not convert string to float: ‘message’

It happens when I run the code:

query = ['How to concat dataframes pandas']
query_embedding = embedding_model.get_embeddings(query)[0].values

because the query_embedding variable is just the string “message”. I’ve tried restarting the kernel but no luck. Has anyone had this problem before? Anyone know how to solve it?


Hi @indiaj27

Welcome to the community.

Make sure you haven’t change any code on the notebook.

I did a couple tests and everything is work just fine.

Also, are you trying to running locally or trough the course platform?

best regards

Hi @elirod

I haven’t changed anything in the notebook and I’m running it through the course platform.

I just tried again and it’s still failing at the same point. Any idea?


The error states that it is something wrong with some kind of parse operation. It is like that the code is trying to convert the query to a float value.

please, send me your notebook. you can do that by click on my avatar and hit the message button.

Yes, it’s because the value of query_embedding is just the string “message” but the cosine_similarity method is expecting an embedding. So I assume something is going wrong with the embedding

1 Like

I running your notebook and wasn’t able to reproduce this error.

In fact, a got other output when a try to show the query_embedding variable.

Are you running all the code cells from top to bottom?

Yes, I just do “Restart Kernel and Run All” to be sure and that’s the output I get. I was able to run the previous exercises without any issue but not this one for some reason

Just an update, I’ve gone back to one of the previous exercises that was working before and now it’s no longer working either. I now get an error when trying to connect to BigQuery, so it seems to be some sort of authentication issue with the API, right?

I’m just using the default credentials by the way:

Please, try another browser, just to make sure that it is not a cache issue.

I just tried Chrome and Firefox and both have exactly the same issue

1 Like

Try to run one by one. Run all the cells at once makes to hard to debbug

Just a tip: Make sure that you restarted and clean all the outputs and refresh the page before to running the cells again.


Thanks for the tips! I just tried that and it’s still not working unfortunately. Not sure if it’s related but I’m getting this little “error” badge at the top of the notebook next to the kernel after running the very first cell

I tried creating a new kernel and a new notebook and copying and pasting the code in but that still didn’t seem to work

i’m ran out of ideas. I tried some troubleshooting and everything works just fine for me.

Maybe we facing some kind of instability of the course in some locations. I’m not sure if it is the case.

We can try some troubleshooting in your end.

please, check if there is some kind a antvirus, firewall or VPN that might be affecting you.

Also, if it is some kind of instability on our side, it might be solve anytime soon.

thanks for your patience.

1 Like

Ok, thanks for trying! I have made sure the VPN is disconnected but I will check those other things you mentioned and try again tomorrow.

1 Like

So far it hasn’t been resolved, but I got another error this time. Not sure if this is helpful in debugging, but when i run the authenticate step i get this message. Do you think this is having an impact?

Also something else strange. When i click Restart Kernel and Clear Output, the cells are cleared. But when i refresh the page, the state is restored with the outputs. So I’m not sure if this restart and clear is actually working (I cleared my browser cache in between and it still didn’t work)

I think you have a serious browser or internet connection problem. Your browser is showing you a locally cached page instead of the live page from the server.

1 Like

Yep! I got this error before. I Think it is not a error, but a warning.

Never the less, i still unable to reproduce the error that you report before. Everything is work just fine for me.

@TMosh brings us a good point. Maybe you have some trouble with your internet connection.