HackMD
    • Sharing Link copied
    • /edit
    • View mode
      • Edit mode
      • View mode
      • Book mode
      • Slide mode
      Edit mode View mode Book mode Slide mode
    • Note Permission
    • Read
      • Only me
      • Signed-in users
      • Everyone
      Only me Signed-in users Everyone
    • Write
      • Only me
      • Signed-in users
      • Everyone
      Only me Signed-in users Everyone
    • More (Comment, Invitee)
    • Publishing
    • Commenting Enable
      Disabled Forbidden Owners Signed-in users Everyone
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Invitee
    • No invitee
    • Options
    • Versions
    • Transfer ownership
    • Delete this note
    • Template
    • Save as template
    • Insert from template
    • Export
    • Google Drive Export to Google Drive
    • Gist
    • Import
    • Google Drive Import from Google Drive
    • Gist
    • Clipboard
    • Download
    • Markdown
    • HTML
    • Raw HTML
Menu Sharing Help
Menu
Options
Versions Transfer ownership Delete this note
Export
Google Drive Export to Google Drive Gist
Import
Google Drive Import from Google Drive Gist Clipboard
Download
Markdown HTML Raw HTML
Back
Sharing
Sharing Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
More (Comment, Invitee)
Publishing
More (Comment, Invitee)
Commenting Enable
Disabled Forbidden Owners Signed-in users Everyone
Permission
Owners
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Invitee
No invitee
   owned this note    owned this note      
Published Linked with
Like BookmarkBookmarked
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Cofacts category review generator design document This document describes the manual review process of training data fed into Cofacts [rumors-ai-bert](https://github.com/cofacts/rumors-ai-bert) model. ## Traning data generation flow ``` Elasticsearch --(Script 1)-> spreadsheets --(Script 2)-> JSON files per article Write to Elasticsearch (to be included in next (1) run) ``` The two scripts: - Script 1: A `rumors-api` script, `genCategoryReview`, that generates an xlsx file of items to review. - Script 2: A `rumors-api` script, `genBERTInputArticles`, that (a) generates a zip with JSON for each article to train, and (b) writes to Elasticsearch so that the review result will be included in the next run. Target JSON for one article are as follows, in which `tags` being the ground truth for the classifier: ```json { "createdAt": "2018-11-14T01:24:49.719Z", "hyperlinks": "", "id": "1pt6j5jf6s6dq", "reference": "LINE", "tags": ["lT3h7XEBrIRcahlYugqq"], "text": "自中國進口水壺蓋 太和工房被爆驗出殘渣值超標57倍", "url": "https://cofacts.g0v.tw/article/1pt6j5jf6s6dq" } ``` All ground truth labels (category IDs in `tags`) should be "Human reviewed" a.k.a. - Human tags that is reviewed - AI tags that is "agreed" by users and is reviewed by users Categories to *not* put in `tags`: - Tags (AI / Human) that is not reviewed by anyone. - Tags (AI / Human) that user that has more "disagreed" than "agreed" Therefore, we design Script 2 to only include tags with positive scores (article-category feedback score sum) in the resulting JSON's `tags`. For each `articleCategory`, the scripts would process them in the following logic: - If the article-category is added by AI: ``` Some user "agrees" (positive articleCategoryFeedback) --> Script 1 include it in review --(adopted)--> Script 2 adds another "Agree" (positive articleCategoryFeedback) --> It has score +2; will be included in JSONs --(not adopted)--> Script 2 adds a "Disagree" (negative articleCategoryFeedback) --> It has score +0; will not be included in JSONs ``` - If the article-category is added by human: ``` Script 1 include it in review directly --(adopted)--> Script 2 adds one "Agree" (positive articleCategoryFeedback) --> It has score +1; will be included in JSONs --(not adopted)--> Script 2 adds a "Disagree" (negative articleCategoryFeedback) --> It has score -1; will not be included in JSONs, and is not counted as a valid category ``` ## Script 1. `genCategoryReview` script in `rumors-api` ### Input Date of `articleCategory` to start scanning for article categories of interest. ### Output A xlsx file with the following sheets: - article-category sheet: the article-categories to review - article id (vertical merge cell if duplicated with last row) - article text (vertical merge cell if duplicated with last row) - category title to review - other's deny reasons - adopt? (User input; used by script 2) - deny reason (User input; used by script 2) - mapping sheet: category ID v.s. category title :::info Sample file: https://docs.google.com/spreadsheets/d/1pAd93Lnaa-L1r6r5b7h1E94IDSqvQxmvMN7XvMkQZXE/edit#gid=1075473317 ::: ### Execution - Prepare xlsx file with the sheets - Loop through all `articleCategoryFeedbacks`, record the following info per article-category: - total score - latest feedback date by others (not we the reviewers) - our (appId = `rumors-ai`, userId = `category-reviewer`) previous vote on this article-reply (if there is any) - our deny reason if previously denied (if there is any) - negative feedback reasons by others - Loop through all article: - Collect article categories of interest, which is defined as: - date criteria - creation date >= input date, or - latest feedback date by others (not we the reviewers) >= input date - created by website user, or created by AI (has `aiModel`) with positive total score - skip the article if there is no article categories of interest - add a row to the article-category sheet for each article categories of interest - Auto fill true in "adopt?" if previously adopted - Auto fill out deny reason in "deny reason" if previously denied - After the xlsx file is generated, we can manually import it to Google sheet and start human reviews. ## Script 2. `genBERTInputArticles` script in `rumors-api` ### Input - A public google sheet ID ### Output 1. Write review results (adopted / deny reason) to ElasticSearch as `articlecategoryfeedbacks`. - Entry appId: `rumors-ai` - Entry userId: `category-reviewer` 3. A zip file of JSON in the following format: ```json { "createdAt": "2018-11-14T01:24:49.719Z", "hyperlinks": "", "id": "1pt6j5jf6s6dq", "reference": "LINE", "tags": ["lT3h7XEBrIRcahlYugqq"], "text": "自中國進口水壺蓋 太和工房被爆驗出殘渣值超標57倍", "url": "https://cofacts.g0v.tw/article/1pt6j5jf6s6dq" } ``` ### Execution 1. Validate sheet - Validate the mapping sheet is identical to the current database's. - If not, user should fix the spreadsheet so that trained model can be used on production - Validate all added / removed category in the article-category sheet are inside the mapping sheet 2. Write info in sheet to Elasticsearch - Group rows in article-category sheet by article ID - Record `latestArticleCategoryCreatedAt`, which is the latest `createdAt` timestamp among all article-category in sheet - For each adopted categories: Write / update positive `articleCategoryFeedback` - For each denied catategories: Write / update negative `articleCategoryFeedback` - Update vote count in article-category 3. Generate article JSON files - Scans through all articles - put article-categories with at least 1 upvote in `tags` in the JSON - Skip new article-categories with `createdAt > latestArticleCategoryCreatedAt`. These article-categories are created after Script 1 is run and is not reviewed yet. - If `tags` array is not empty, emit 1 JSON file for the article ## Future TODO 1. Fix old categories such as AIDS 2. Subgroup category handling - e.g. If the article has COVID-19, add 醫藥 - Maybe it should be implemented as part of application logic, i.e. 醫藥 is added automatically when the article is marked as COVID-19 or AIDS.

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lost their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.


Upgrade

All
  • All
  • Team
No template.

Create a template


Upgrade

Delete template

Do you really want to delete this template?

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

Sign in via GitHub

New to HackMD? Sign up

Help

  • English
  • 中文
  • 日本語

Documents

Tutorials

Book Mode Tutorial

Slide Example

YAML Metadata

Resources

Releases

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions

Versions

Upgrade now

Version named by    

More Less
  • Edit
  • Delete

Note content is identical to the latest version.
Compare with
    Choose a version
    No search result
    Version not found

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.