{"id":25689542,"url":"https://github.com/zcemycl/qa-chatgpt-hf-pgvector","last_synced_at":"2026-04-12T09:07:08.025Z","repository":{"id":208618076,"uuid":"715836986","full_name":"zcemycl/qa-chatgpt-hf-pgvector","owner":"zcemycl","description":"E-commerce fashion assistant with Chatgpt, Hugging Face, Ltree and Pgvector.","archived":false,"fork":false,"pushed_at":"2023-11-15T23:01:08.000Z","size":2302,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-17T10:53:18.556Z","etag":null,"topics":["captioning-images","chatgpt","cosine-similarity","docker-compose","dockerfile","embeddings","guardrails","huggingface","huggingface-transformers","image-to-text","jupyter-notebook","ltree","openai","pgvector","postgresql","python","sqlalchemy"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zcemycl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-11-07T23:44:09.000Z","updated_at":"2024-04-14T00:14:48.000Z","dependencies_parsed_at":"2023-11-22T12:49:02.136Z","dependency_job_id":null,"html_url":"https://github.com/zcemycl/qa-chatgpt-hf-pgvector","commit_stats":null,"previous_names":["zcemycl/qa-chatgpt-hf-pgvector"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcemycl%2Fqa-chatgpt-hf-pgvector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcemycl%2Fqa-chatgpt-hf-pgvector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcemycl%2Fqa-chatgpt-hf-pgvector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zcemycl%2Fqa-chatgpt-hf-pgvector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zcemycl","download_url":"https://codeload.github.com/zcemycl/qa-chatgpt-hf-pgvector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240564595,"owners_count":19821421,"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":["captioning-images","chatgpt","cosine-similarity","docker-compose","dockerfile","embeddings","guardrails","huggingface","huggingface-transformers","image-to-text","jupyter-notebook","ltree","openai","pgvector","postgresql","python","sqlalchemy"],"created_at":"2025-02-24T22:01:26.431Z","updated_at":"2025-10-23T23:59:15.989Z","avatar_url":"https://github.com/zcemycl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# qa-chatgpt-pgvector\n\n|1. Produce Advice|2. Customer Conversation|\n|---|---|\n|\u003cimg src=\"resources/mode1.png\" height=\"190\"\u003e|\u003cimg src=\"resources/sample.png\" height=\"190\" width=\"250\"\u003e|\n|3. Similar Garments Image Search|4. Complementarity Garments Suggestion|\n|\u003cimg src=\"resources/mode3.png\" height=\"190\"\u003e|\u003cimg src=\"resources/mode4.png\" height=\"190\"\u003e|\n\n\n## Schedule (8-15 Nov)\n1. docker-compose.yml + Dockerfile.pgvector -\u003e 8 Nov\n    - initialise a database with vector support.\n1. test-openai.ipynb\n    - test openai==1.1.1 api, including embeddings and chat completions.\n2. create-embeddings.ipynb\n    - create embeddings for all articles.\n    - discover 3 nan details in record.\n    - store embeddings in postgres using pgvector.\n3. doc-search.ipynb\n    - prove that pgvector can help cosine similiarity calculation.\n    - only embedding details from dataframe are not enough as answers can be inaccurate.\n    - try question-answering with given information.\n4. chatbot.ipynb\n    - implement chat completion loop.\n5. guardrail_openai-0-28-1.ipynb\n    - try guardrails-ai.\n    - switch openai version to 0.28.x as 1.1.x is not compatible with guardrails-ai.\n    - try all embeddings and chat completions in 0.28.x openai api.\n6. qa_package.main (Mode 1 and 2) -\u003e 9 Nov\n    - create chatbot.\n7. hf-captions.ipynb -\u003e 12 Nov\n    - test gpt4 vision, it requires payment to use. (rejected)\n    - test hugging face Salesforce/blip-image-captioning-base model for captioning.\n    - analyse if clusterings can help suggestion in same or different categories.\n8. qa_package.main (Mode 3) -\u003e 13 Nov\n    - find garments based on text + image.\n9. ltree.ipynb\n    - test ltree in postgres to group product groups and types.\n    - create color embedding\n    - create pattern embedding\n    - create garment embedding + setn.{product group}.{product type} as ltree path.\n10. qa_package.main (Mode 4) -\u003e 15 Nov\n    - suggest complementarity garments based on text + image.\n\n\n## How to run?\n1. Edit environment variables.\n    ```\n    cp .env.example .env\n    cp .env jpnotes/\n    # Then fill in .env variables\n    ```\n1. Install required packages. `pip install -e .`\n2. Initialise postgres in Docker. `docker compose up --build`\n3. Run chatbot. (Only run with `--initialise-embeddings` for the first time)\n    ```python\n    python -m qa_package.main \\\n    --batch-size int \\\n    --root-image-dir str \\\n    --article-csv str \\\n    --initialise-embeddings \\\n    --visualise\n    ```\n    for example,\n    ```\n    python -m qa_package.main \\\n    --batch-size 16 \\\n    --initialise-embeddings \\\n    --article-csv /Users/spare/Documents/data/articles.csv \\\n    --root-image-dir /Users/spare/Documents/data/images/ \\\n    --visualise\n    ```\n\n## References\n1. https://pypi.org/project/openai/0.28.1/\n    - Old Documentation of openai 0.28.1\n2. https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/switching-endpoints\n    - openai 0.28.1 vs openai 1.1.1\n3. https://www.kommunicate.io/blog/create-a-customer-service-chatbot-using-chatgpt/\n    - Conversation loop for chatbot.\n4. https://www.mlq.ai/fine-tuning-gpt-3-question-answer-bot/\n    - Question Answering with given information.\n5. https://docs.guardrailsai.com/defining_guards/pydantic/\n    - Define Guardrails with Pydantic.\n6. https://docs.guardrailsai.com/guardrails_ai/getting_started/#creating-a-rail-spec\n    - Guardrails example.\n7. https://cookbook.openai.com/examples/gpt_with_vision_for_video_understanding\n    - openai 0.28.1 can support gpt4 vision preview.\n8. https://huggingface.co/tasks/image-to-text\n    - hugging face image caption model\n9. https://www.kite.com/blog/python/sqlalchemy/\n    - ltree operation in sqlalchemy-utils\n10. https://www.postgresql.org/docs/current/ltree.html\n    - ltree type\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzcemycl%2Fqa-chatgpt-hf-pgvector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzcemycl%2Fqa-chatgpt-hf-pgvector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzcemycl%2Fqa-chatgpt-hf-pgvector/lists"}