#candle #pytorch #crf

candle-crf

porting pytorch-crf to candle

7 releases

0.8.5 Oct 15, 2024
0.8.4 Sep 19, 2024
0.8.3 Aug 17, 2024
0.7.3 Jul 18, 2024

#222 in Machine learning

Download history 14/week @ 2024-07-24 223/week @ 2024-08-07 203/week @ 2024-08-14 6/week @ 2024-08-21 2/week @ 2024-08-28 1/week @ 2024-09-04 92/week @ 2024-09-18 23/week @ 2024-09-25 8/week @ 2024-10-02 95/week @ 2024-10-09 72/week @ 2024-10-16 4/week @ 2024-10-30 5/week @ 2024-11-06

174 downloads per month

Custom license

82KB
2K SLoC

Candle CRF

Candle CRF ports pytorch-crf to Huggingface Candle.

Initialization

  • Pytorch CRF

    crf = CRF(num_tags, batch_first=false)
    
  • Candle CRF

    let crf = CRF::new(num_tags, false, &candle_core::Device::Cpu).unwrap();
    

Forward

  • Pytorch CRF

    llh = crf(emissions, tags, mask)
    
  • Candle CRF

    let llh = crf
            .forward(&emissions, &tags, Some(&mask), Reduction::default())
            .unwrap();
    

Decode

  • Pytorch CRF

    best_tags = crf.decode(emissions, mask)
    
  • Candle CRF

    let best_tags = crf.decode(&emissions, Some(&mask)).unwrap();
    

Dependencies

~9–19MB
~306K SLoC