mcpField
N
nlp-supply-chain

nlp-supply-chain

github.com/kishorkukrejaデータ・データベース8446 回インストール3 週間前に更新
リポジトリ

nlp-supply-chain について

nlp-supply-chainは、サプライチェーン業務で非構造化テキストの分析や文書処理、製品分類を支援するNLPスキルです。BERTによる分類、請求書のエンティティ抽出、サプライヤーリスク分析、問い合わせチャットボットを扱います。

主な機能

  1. 01発注書・請求書・契約書の処理
  2. 02BERTによる製品分類
  3. 03請求書の固有表現認識
  4. 04サプライヤーリスクの感情分析
  5. 05サプライチェーン問い合わせチャットボット

活用シーン

  1. 01請求書からエンティティを抽出
  2. 02説明文に基づく製品分類
  3. 03ニュースやレポートによるサプライヤーリスク分析
  4. 04社内のサプライチェーン問い合わせへの回答

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/kishorkukreja/awesome-supply-chain --skill nlp-supply-chain

インストール後、Claude Code で/nlp-supply-chainを入力して読み込まれたか確認します。

詳細

サプライチェーンの自然言語処理

サプライチェーンの課題に NLP を適用するエキスパートです。目標は、非構造化テキストからインサイトを抽出し、文書処理を自動化し、サプライヤーとのコミュニケーションを分析し、最新の NLP 技術を使って製品を分類することです。

用途

  1. 文書処理:発注書、請求書、契約書
  2. 製品分類:説明文から品目を分類
  3. サプライヤーリスク分析:ニュース、レポート、感情を分析
  4. 需要センシング:ソーシャルメディア、レビュー、トレンド
  5. チャットボット:カスタマーサービス、社内の問い合わせ

BERT による製品分類

from transformers import BertTokenizer, BertForSequenceClassification
import torch

class ProductClassifier:
    """
    Classify products from text descriptions using BERT
    """
    
    def __init__(self, num_classes):
        self.tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
        self.model = BertForSequenceClassification.from_pretrained(
            'bert-base-uncased',
            num_labels=num_classes
        )
    
    def classify(self, product_description):
        """Classify product from description"""
        
        # Tokenize
        inputs = self.tokenizer(
            product_description,
            return_tensors='pt',
            truncation=True,
            padding=True,
            max_length=128
        )
        
        # Predict
        with torch.no_grad():
            outputs = self.model(**inputs)
            logits = outputs.logits
            predicted_class = torch.argmax(logits, dim=1).item()
        
        return predicted_class

請求書向け固有表現認識(NER)

from transformers import pipeline

class InvoiceExtractor:
    """
    Extract entities from invoices using NER
    """
    
    def __init__(self):
        self.ner = pipeline("ner", model="dbmdz/bert-large-cased-finetuned-conll03-english")
    
    def extract_entities(self, invoice_text):
        """Extract company names, dates, amounts"""
        
        entities = self.ner(invoice_text)
        
        extracted = {
            'companies': [],
            'dates': [],
            'amounts': []
        }
        
        for ent in entities:
            if ent['entity'].startswith('B-ORG') or ent['entity'].startswith('I-ORG'):
                extracted['companies'].append(ent['word'])
            elif ent['entity'].startswith('B-DATE'):
                extracted['dates'].append(ent['word'])
        
        return extracted

サプライヤーリスクの感情分析

from transformers import pipeline

class SupplierRiskAnalyzer:
    """
    Analyze supplier risk from news and reports
    """
    
    def __init__(self):
        self.sentiment_analyzer = pipeline("sentiment-analysis")
    
    def analyze_news(self, articles):
        """Analyze sentiment of news about supplier"""
        
        sentiments = []
        for article in articles:
            result = self.sentiment_analyzer(article['text'])[0]
            sentiments.append({
                'article': article['title'],
                'sentiment': result['label'],
                'score': result['score']
            })
        
        # Aggregate risk
        negative_count = sum(1 for s in sentiments if s['sentiment'] == 'NEGATIVE')
        risk_score = negative_count / len(sentiments)
        
        return {
            'risk_score': risk_score,
            'sentiments': sentiments
        }

サプライチェーンの問い合わせに対応するチャットボット

from transformers import AutoModelForCausalLM, AutoTokenizer

class SupplyChainChatbot:
    """
    Chatbot for internal supply chain queries
    """
    
    def __init__(self):
        self.tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
        self.model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-medium")
    
    def respond(self, user_input, chat_history):
        """Generate response to user query"""
        
        # Encode input
        new_input_ids = self.tokenizer.encode(
            user_input + self.tokenizer.eos_token,
            return_tensors='pt'
        )
        
        # Generate response
        chat_history_ids = torch.cat([chat_history, new_input_ids], dim=-1)                           if chat_history is not None else new_input_ids
        
        response_ids = self.model.generate(
            chat_history_ids,
            max_length=1000,
            pad_token_id=self.tokenizer.eos_token_id
        )
        
        response = self.tokenizer.decode(
            response_ids[:, chat_history_ids.shape[-1]:][0],
            skip_special_tokens=True
        )
        
        return response, response_ids

ツールとライブラリ

  • transformers (Hugging Face):BERT、GPT、T5
  • spaCy:産業向け NLP
  • NLTK:テキスト処理
  • Gensim:トピックモデリング
  • OpenAI API:GPT-4 との統合

関連スキル

  • ml-supply-chain:一般的な ML
  • **supplier-risk-management`: リスク分析
  • demand-forecasting:テキストからの需要センシング

コメント