{"id":13456732,"url":"https://github.com/THUDM/WebGLM","last_synced_at":"2025-03-24T11:31:09.339Z","repository":{"id":175130037,"uuid":"646488027","full_name":"THUDM/WebGLM","owner":"THUDM","description":"WebGLM: An Efficient Web-enhanced Question Answering System (KDD 2023)","archived":false,"fork":false,"pushed_at":"2024-12-13T06:39:35.000Z","size":6486,"stargazers_count":1583,"open_issues_count":52,"forks_count":138,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-03-16T15:05:19.754Z","etag":null,"topics":["chatgpt","llm","rlhf","webglm"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/THUDM.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-28T15:02:26.000Z","updated_at":"2025-03-09T09:32:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"577e0a79-f122-4b8a-be9e-3deda1b31d38","html_url":"https://github.com/THUDM/WebGLM","commit_stats":{"total_commits":28,"total_committers":4,"mean_commits":7.0,"dds":0.4285714285714286,"last_synced_commit":"74d3bcac3b1b7d4ec35e21a33677f5ed92a08fed"},"previous_names":["thudm/webglm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUDM%2FWebGLM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUDM%2FWebGLM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUDM%2FWebGLM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THUDM%2FWebGLM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/THUDM","download_url":"https://codeload.github.com/THUDM/WebGLM/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245119589,"owners_count":20563763,"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":["chatgpt","llm","rlhf","webglm"],"created_at":"2024-07-31T08:01:26.796Z","updated_at":"2025-03-24T11:31:09.331Z","avatar_url":"https://github.com/THUDM.png","language":"Python","readme":"\u003ch1\u003eWebGLM: Towards An Efficient Web-enhanced Question Answering System with Human Preferences\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e📃 \u003ca href=\"https://arxiv.org/pdf/2306.07906.pdf\" target=\"_blank\"\u003ePaper (KDD'23)\u003c/a\u003e • 🌐 \u003ca href=\"https://github.com/THUDM/WebGLM/blob/main/README_zh.md\" target=\"_blank\"\u003e中文 README\u003c/a\u003e • 🤗 HF Repo \u003ca href=\"https://huggingface.co/THUDM/WebGLM\" target=\"_blank\"\u003e[WebGLM-10B]\u003c/a\u003e \u003ca href=\"https://huggingface.co/THUDM/WebGLM-2B\" target=\"_blank\"\u003e[WebGLM-2B]\u003c/a\u003e • 📚 Dataset \u003ca href=\"https://huggingface.co/datasets/THUDM/webglm-qa\" target=\"_blank\"\u003e[WebGLM-QA]\u003c/a\u003e\u003c/p\u003e\n\nThis is the official implementation of WebGLM. If you find our open-sourced efforts useful, please 🌟 the repo to encourage our following developement!\n\n\u003c!--https://github.com/THUDM/WebGLM/assets/129033897/d2e1dd35-6340-4175-ac2d-fd585daa17cf--\u003e\n\n**[Please click to watch the demo!]**\n\n[![Click to Watch Demo!](https://img.youtube.com/vi/ohjrlYCLLEU/0.jpg)](https://www.youtube.com/watch?v=ohjrlYCLLEU)\n\n_Read this in [中文](README_zh.md)._\n\n## Update\n**[2023/06/25]** Release [ChatGLM2-6B](https://github.com/THUDM/ChatGLM2-6B), an updated version of [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B) which introduces several new features:\n\n1. **Stronger Performance**: we have fully upgraded the ChatGLM2-6B. It uses the hybrid objective function of [GLM](https://github.com/THUDM/GLM), and has undergone pre-training with 1.4T bilingual tokens and human preference alignment training. The [evaluation results](README.md#evaluation-results) show that, compared to the first-generation model, ChatGLM2-6B has achieved substantial improvements in performance on datasets like MMLU (+23%), CEval (+33%), GSM8K (+571%), BBH (+60%), showing strong competitiveness among models of the same size.\n2. **Longer Context**: Based on [FlashAttention](https://github.com/HazyResearch/flash-attention) technique, we have extended the context length of the base model from 2K in ChatGLM-6B to 32K, and trained with a context length of 8K during the dialogue alignment, allowing for more rounds of dialogue. However, the current version of ChatGLM2-6B has limited understanding of single-round ultra-long documents, which we will focus on optimizing in future iterations.\n3. **More Efficient Inference**: Based on [Multi-Query Attention](http://arxiv.org/abs/1911.02150) technique, ChatGLM2-6B has more efficient inference speed and lower GPU memory usage: under the official  implementation, the inference speed has increased by 42% compared to the first generation; under INT4 quantization, the dialogue length supported by 6G GPU memory has increased from 1K to 8K.\n\nMore details please refer to [ChatGLM2-6B](https://github.com/THUDM/ChatGLM2-6B)。\n\n\u003c!-- TOC --\u003e\n\n-   [Overview](#overview)\n    -   [Features](#features)\n-   [News](#news)\n-   [Preparation](#preparation)\n    -   [Prepare Code and Environments](#prepare-code-and-environments)\n    -   [Prepare SerpAPI Key](#prepare-serpapi-key)\n    -   [Prepare Retriever Checkpoint](#prepare-retriever-checkpoint)\n-   [Try WebGLM](#try-webglm)\n    -   [Export Environment Variables](#export-environment-variables)\n    -   [Run as Command Line Interface](#run-as-command-line-interface)\n    -   [Run as Web Service](#run-as-web-service)\n-   [Train WebGLM](#train-webglm)\n    -   [Train Generator](#train-generator)\n        -   [Prepare Data](#prepare-data)\n        -   [Training](#training)\n    -   [Train Retriever](#train-retriever)\n        -   [Prepare Data](#prepare-data-1)\n        -   [Training](#training-1)\n-   [Evaluation](#evaluation)\n-   [Real Application Cases](#real-application-cases)\n-   [Citation](#citation)\n\n# Overview\n\n![paper](./assets/main_process.png)\n\nWebGLM aspires to provide an efficient and cost-effective web-enhanced question-answering system using the 10-billion-parameter General Language Model (GLM). It aims to improve real-world application deployment by integrating web search and retrieval capabilities into the pre-trained language model.\n\n## Features\n\n-   **LLM-augmented Retriever**: Enhances the retrieval of relevant web content to better aid in answering questions accurately.\n-   **Bootstrapped Generator**: Generates human-like responses to questions, leveraging the power of the GLM to provide refined answers.\n-   **Human Preference-aware Scorer**: Estimates the quality of generated responses by prioritizing human preferences, ensuring the system produces useful and engaging content.\n\n# News\n\n-   **[2023-06-24]** We support searching via [Bing](https://www.bing.com/) now!\n-   **[2023-06-14]** We release our code and the [paper](https://arxiv.org/pdf/2306.07906.pdf) of WebGLM!\n\n# Preparation\n\n## Prepare Code and Environments\n\nClone this repo, and install python requirements.\n\n```bash\npip install -r requirements.txt\n```\n\nInstall Nodejs.\n\n```bash\napt install nodejs # If you use Ubuntu\n```\n\nInstall playwright dependencies.\n\n```bash\nplaywright install\n```\n\nIf browsing environments are not installed in your host, you need to install them. Do not worry, playwright will give you instructions when you first execute it if so.\n\n## Prepare SerpAPI Key\n\nIn search process, we use SerpAPI to get search results. You need to get a SerpAPI key from [here](https://serpapi.com/).\n\nThen, set the environment variable `SERPAPI_KEY` to your key.\n\n```bash\nexport SERPAPI_KEY=\"YOUR KEY\"\n```\n\nAlternatively, you can use Bing search with local browser environment (playwright). You can add `--searcher bing` to start command lines to use Bing search. (See [Run as Command Line Interface](#run-as-command-line-interface) and [Run as Web Service](#run-as-web-service))\n\n## Prepare Retriever Checkpoint\n\nDownload the checkpoint on [ModelScope](https://www.modelscope.cn/models/shawliu9/webglm-contriever) by running the command line below.\n\nYou can manually specify the path to save the checkpoint by `--save SAVE_PATH`.\n\n```bash\npython download.py retriever-pretrained-checkpoint\n```\n\n# Try WebGLM\n\nBefore you run the code, make sure that the space of your device is enough.\n\n## Export Environment Variables\n\nExport the environment variable `WEBGLM_RETRIEVER_CKPT` to the path of the retriever checkpoint. If you have downloaded the retriever checkpoint in the default path, you can simply run the command line below.\n\n```bash\nexport WEBGLM_RETRIEVER_CKPT=./download/retriever-pretrained-checkpoint\n```\n\n## Run as Command Line Interface\n\nYou can try WebGLM-2B model by:\n\n```bash\npython cli_demo.py -w THUDM/WebGLM-2B\n```\n\nOr directly for WebGLM-10B model:\n\n```bash\npython cli_demo.py\n```\n\nIf you want to use Bing search instead of SerpAPI, you can add `--searcher bing` to the command line, for example:\n\n```bash\npython cli_demo.py -w THUDM/WebGLM-2B --searcher bing\n```\n\n## Run as Web Service\n\nRun `web_demo.py` with the same arguments as `cli_demo.py` to start a web service.\nFor example, you can try WebGLM-2B model with Bing search by:\n\n```bash\npython web_demo.py -w THUDM/WebGLM-2B --searcher bing\n```\n\n# Train WebGLM\n\n## Train Generator\n\n### Prepare Data (WebGLM-QA)\n\nDownload the training data (WebGLM-QA) on [Tsinghua Cloud](https://cloud.tsinghua.edu.cn/d/d290dcfc92e342f9a017/) by running the command line below.\n\n```bash\npython download.py generator-training-data\n```\n\nIt will automatically download all the data and preprocess them into the seq2seq form that can be used immediately in `./download`.\n\n### Training\n\nPlease refer to [GLM repo](https://github.com/THUDM/GLM#train-with-your-own-data) for seq2seq training.\n\n## Train Retriever\n\n### Prepare Data\n\nDownload the training data on [Tsinghua Cloud](https://cloud.tsinghua.edu.cn/d/3927b67a834c475288e2/) by running the command line below.\n\n```bash\npython download.py retriever-training-data\n```\n\n### Training\n\nRun the following command line to train the retriever. If you have downloaded the retriever training data in the default path, you can simply run the command line below.\n\n```bash\npython train_retriever.py --train_data_dir ./download/retriever-training-data\n```\n\n# Evaluation\n\nYou can reproduce our results on TriviaQA, WebQuestions and NQ Open. Take TriviaQA for example, you can simply run the command line below:\n\n```bash\nbash scripts/triviaqa.sh\n```\n\nand start running the experiment.\n\n# Real Application Cases\n\n[Here](assets/cases) you can see some examples of WebGLM real application scenarios.\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eWhen will the COVID-19 disappear?\u003c/b\u003e\u003c/summary\u003e\n\n![](assets/cases/0.png)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eHow to balance career and hobbies?\u003c/b\u003e\u003c/summary\u003e\n\n![](assets/cases/1.png)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eFL Studio and Cubase, which is better?\u003c/b\u003e\u003c/summary\u003e\n\n![](assets/cases/2.png)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eIs attention better than CNN?\u003c/b\u003e\u003c/summary\u003e\n\n![](assets/cases/3.png)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eHow to survive in the first-tier cities without a high-salary work?\u003c/b\u003e\u003c/summary\u003e\n\n![](assets/cases/4.png)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eWhat do you think of version 3.5 of Genshin Impact?\u003c/b\u003e\u003c/summary\u003e\n\n![](assets/cases/5.png)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003etransformers are originated in NLP, but why they can be applied in CV?\u003c/b\u003e\u003c/summary\u003e\n\n![](assets/cases/6.png)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eWho proposed Music Transformer? How does it work?\u003c/b\u003e\u003c/summary\u003e\n\n![](assets/cases/7.png)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eWhat is the backbone of Toolformer?\u003c/b\u003e\u003c/summary\u003e\n\n![](assets/cases/8.png)\n\n\u003c/details\u003e\n\n# License\n\nThis repository is licensed under the [Apache-2.0 License](LICENSE). The use of model weights is subject to the [Model_License](MODEL_LICENSE). All open-sourced data is for resarch purpose only.\n\n# Citation\n\nIf you use this code for your research, please cite our paper.\n\n```\n@misc{liu2023webglm,\n      title={WebGLM: Towards An Efficient Web-Enhanced Question Answering System with Human Preferences},\n      author={Xiao Liu and Hanyu Lai and Hao Yu and Yifan Xu and Aohan Zeng and Zhengxiao Du and Peng Zhang and Yuxiao Dong and Jie Tang},\n      year={2023},\n      eprint={2306.07906},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL}\n}\n```\n\n\u003e This repo is simplified for easier deployment.\n","funding_links":[],"categories":["Python","A01_文本生成_文本对话","Papers","Applications","ChatGPT-based applications for regular users and specialized problems"],"sub_categories":["大语言对话模型及数据","Frameworks \u0026 Models","提示语（魔法）","Other sdk/libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTHUDM%2FWebGLM","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTHUDM%2FWebGLM","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTHUDM%2FWebGLM/lists"}