{"id":21407182,"url":"https://github.com/daveshap/embeddingservice","last_synced_at":"2025-07-14T00:33:24.692Z","repository":{"id":50363348,"uuid":"292090669","full_name":"daveshap/EmbeddingService","owner":"daveshap","description":"REST API microservice for handling Universal Sentence Encoder","archived":false,"fork":false,"pushed_at":"2022-08-24T08:00:34.000Z","size":7,"stargazers_count":17,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-30T09:28:51.479Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daveshap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-01T19:35:56.000Z","updated_at":"2024-03-14T05:47:13.000Z","dependencies_parsed_at":"2022-07-29T01:08:16.319Z","dependency_job_id":null,"html_url":"https://github.com/daveshap/EmbeddingService","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveshap%2FEmbeddingService","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveshap%2FEmbeddingService/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveshap%2FEmbeddingService/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daveshap%2FEmbeddingService/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daveshap","download_url":"https://codeload.github.com/daveshap/EmbeddingService/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225933977,"owners_count":17547728,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T16:44:57.170Z","updated_at":"2024-11-22T16:44:59.050Z","avatar_url":"https://github.com/daveshap.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Universal Sentence Encoder Microservice\n\nUltra simple REST API microservice for handling Google Universal Sentence Encoder.\n\n## Tutorial\n\n1. Create an Anaconda environment with `tensorflow_hub` and `flask`.\n2. Start the Anaconda environment and run `USEv4_microservice.py`.\n3. Use the `client.py` to get an example of the usage.\n4. Simply perform an HTTP POST to http://localhost:999 where the payload is a list of strings i.e. `[\"This is a string to embed.\", \"This is also a string to embed.\"]`\n5. The microservice will embed the sentences as semantic vectors and return a list of dictionaries i.e. `[{\"string\":\"original sentence\",\"vector\":\"#####\"}]`\n\n## Examples\n\nHow the microservice looks:\n\n```bash\n(tf2_gpu) C:\\USE_microservice\u003epython USEv4_microservice.py\n2020-09-01 16:04:28.485293: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll\n2020-09-01 16:04:31.989725: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll\n2020-09-01 16:04:32.093989: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:\npciBusID: 0000:01:00.0 name: GeForce RTX 2070 computeCapability: 7.5\ncoreClock: 1.71GHz coreCount: 36 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s\n2020-09-01 16:04:32.105438: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll\n2020-09-01 16:04:32.116839: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll\n2020-09-01 16:04:32.136340: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll\n2020-09-01 16:04:32.143902: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll\n2020-09-01 16:04:32.151881: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll\n2020-09-01 16:04:32.168041: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll\n2020-09-01 16:04:32.184134: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll\n2020-09-01 16:04:32.189162: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0\n2020-09-01 16:04:32.193567: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2\n2020-09-01 16:04:32.210366: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:\npciBusID: 0000:01:00.0 name: GeForce RTX 2070 computeCapability: 7.5\ncoreClock: 1.71GHz coreCount: 36 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s\n2020-09-01 16:04:32.217849: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll\n2020-09-01 16:04:32.222040: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll\n2020-09-01 16:04:32.226238: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll\n2020-09-01 16:04:32.229364: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll\n2020-09-01 16:04:32.233889: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll\n2020-09-01 16:04:32.238114: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll\n2020-09-01 16:04:32.242769: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll\n2020-09-01 16:04:32.246926: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0\n2020-09-01 16:04:32.938683: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:\n2020-09-01 16:04:32.942336: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]      0\n2020-09-01 16:04:32.944987: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0:   N\n2020-09-01 16:04:32.950180: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6306 MB memory) -\u003e physical GPU (device: 0, name: GeForce RTX 2070, pci bus id: 0000:01:00.0, compute capability: 7.5)\n * Serving Flask app \"encoder\" (lazy loading)\n * Environment: production\n   WARNING: This is a development server. Do not use it in a production deployment.\n   Use a production WSGI server instead.\n * Debug mode: off\nINFO:werkzeug: * Running on http://0.0.0.0:999/ (Press CTRL+C to quit)\n['This is a sentence', 'this is a second sentence']\n2020-09-01 16:04:47.884356: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll\nINFO:werkzeug:127.0.0.1 - - [01/Sep/2020 16:04:48] \"\u001b[37mPOST / HTTP/1.1\u001b[0m\" 200 -\n['This is a sentence', 'this is a second sentence']\nINFO:werkzeug:127.0.0.1 - - [01/Sep/2020 16:04:52] \"\u001b[37mPOST / HTTP/1.1\u001b[0m\" 200 -\n['This is a sentence', 'this is a second sentence']\nINFO:werkzeug:127.0.0.1 - - [01/Sep/2020 16:04:56] \"\u001b[37mPOST / HTTP/1.1\u001b[0m\" 200 -\n```\n\nHow the client looks:\n\n```bash\nC:\\USE_microservice\u003epython client.py\n[{'string': 'This is a sentence',\n  'vector': '[0.028817661106586456, -0.020200150087475777, '\n            '0.010696266777813435, 0.03850530833005905, -0.09253700077533722, '\n            '0.017527734860777855, -0.04711754620075226, 0.047852084040641785, '\n\t\t\t........\n            '0.1103242039680481, -0.013840682804584503, -0.009360543452203274, '\n            '0.02323107048869133, 0.0042100404389202595, '\n            '-0.028969207778573036, 0.008764670230448246, '\n            '0.08242126554250717]'},\n {'string': 'this is a second sentence',\n  'vector': '[0.04119128733873367, -0.033451974391937256, '\n            '-0.02913030795753002, 0.07749398797750473, -0.09640706330537796, '\n            '0.033736273646354675, -0.01458499301224947, 0.012801065109670162, '\n\t\t\t........\n            '0.01435331255197525, -0.045849379152059555, '\n            '-0.017022253945469856, -0.02670147269964218, '\n            '-0.04068242385983467, 0.08653835952281952]'}]\nTotal time: 0.017948627471923828\n\nC:\\USE_microservice\u003e\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaveshap%2Fembeddingservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaveshap%2Fembeddingservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaveshap%2Fembeddingservice/lists"}